Important Note: I am coding according to C++11 standard
I have to write the following operators for my IntMatrix
class (which check if every element in the matrix is <,>,==,!=,etc...
the given parameter):
IntMatrix operator< (int num) const;
IntMatrix operator> (int num) const;
IntMatrix operator>= (int num) const;
IntMatrix operator<= (int num) const;
IntMatrix operator== (int num) const;
IntMatrix operator!= (int num) const;
So, to prevent code duplications and since the implementation is nearly the same I thought about writing one functor called between(int from, int to)
which checks if number is in a given field.
For example:
for operator>
I would use between(num+1,LargestPossibleint)
for operator<:
between(SmallestPossibleInt,num-1)
for operator==:
between(num,num)
for operator!=:
between(num+1,num-1)
But as you can see my code depends of values like LargestPossibleint and SmallestPossibleInt which I don't want, (And don't believe this is a good solution) May someone suggest an edit for this (Maybe default value for parameters may help)?
Update: I can't use lambda, macros or anything not in standard level What I learnt? All basic stuff in C++, classes, functors, operation overloading, templates, generic code...