mercredi 29 mars 2017

Function doing integer comparison in C++

I am writing a variadic template function which compare multiple integer (like "1 < int_var <= DEFINED_VAR").

For that, I need the prototype of the operator function. I thought it would be:

template<typename T> bool (*comparison_operator)(T, T)

But it does not work. I guess it is because this is not this function that is used for primitive type. I found the "std::less" (and the others operators) online, but it is C++14 and I am stuck with C++11.

Is there a way to do it ? Because, for the moment, the only thing I can think of is replacing every comparison operator by a custom function.

Thanks.

Aucun commentaire:

Enregistrer un commentaire