Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Try this instead:

#include <type_traits> #include <iostream> template <unsigned int N, typename std::enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename std::enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; } int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overloadTemplate default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

Try this instead:

#include <type_traits> #include <iostream> template <unsigned int N, typename std::enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename std::enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; } int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

Try this instead:

#include <type_traits> #include <iostream> template <unsigned int N, typename std::enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename std::enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; } int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

added 308 characters in body
Source Link
vsoftco
  • 56.9k
  • 12
  • 150
  • 269

Try this instead:

#include <type_traits> #include <iostream> using namespace std;  template <unsigned int N, typename std::enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename std::enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; } int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

Try this instead:

#include <type_traits> #include <iostream> using namespace std;  template <unsigned int N, typename enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; } int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

Try this instead:

#include <type_traits> #include <iostream> template <unsigned int N, typename std::enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename std::enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; } int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

added 308 characters in body
Source Link
vsoftco
  • 56.9k
  • 12
  • 150
  • 269

Try this instead:

#include <type_traits> #include <iostream> using namespace std; template <unsigned int N, typename enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; }   int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

Try this instead:

#include <type_traits> #include <iostream> using namespace std; template <unsigned int N, typename enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; }   int main() { my_function<42>(); my_function<100>(); } 

Try this instead:

#include <type_traits> #include <iostream> using namespace std; template <unsigned int N, typename enable_if <N >= 100> :: type* = nullptr> void my_function() { std::cout << "N >= 100" << std::endl; } template <unsigned int N, typename enable_if <N < 100> :: type* = nullptr> void my_function() { std::cout << "N < 100" << std::endl; } int main() { my_function<42>(); my_function<100>(); } 

Template default parameters do not participate in the overload (and hence SFINAE does not apply). On the other hand, in the snippet above, the dependent template non-type parameter is on the left hand side of the assignment, so SFINAE kicks in.

Source Link
vsoftco
  • 56.9k
  • 12
  • 150
  • 269
Loading