This is definitely a trivial question, but I couldn't figure out how to do this.
I have a template function, say template <unsigned int N> void my_function(). Now, I have two different implementations for my_function, the first should be used if N is bigger than, say, 100, the other if N is smaller than that.
I tried to use SFINAE like this:
template <unsigned int N, typename = enable_if <N >= 100> :: type> my_function() { // First implementation } template <unsigned int N, typename = enable_if <N < 100> :: type> my_function() { // Second implementation } But that's declaring the same function two times. Then I tried doing something like
template <unsigned int N, bool = (N >= 100)> my_function(); And then implementing the two functions with the two different values of the boolean. No success, since it is a partial specialization.
Then I tried to wrap N as a struct parameter, and the bool in the function call, but it is specializing a member function before specializing the class, which cannot be done.
Is there a reasonable way to do this?