fork download
  1. #include <type_traits>
  2. #include <cmath>
  3.  
  4. template<typename U = typename std::enable_if<std::is_floating_point<U>::value>::type>
  5. static bool is_equal(U left, U right)
  6. {
  7. return (std::abs(left - right) < 0);
  8. }
  9.  
  10. //
  11. template<typename U = typename std::enable_if<std::is_integral<U>::value>::type>
  12. static bool is_equal(U left, U right)
  13. {
  14. return (left == right);
  15. }
  16.  
  17. int main() {}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:74: error: 'U' was not declared in this scope
     template<typename U = typename std::enable_if<std::is_floating_point<U>::value>::type>
                                                                          ^
prog.cpp:4:75: error: template argument 1 is invalid
     template<typename U = typename std::enable_if<std::is_floating_point<U>::value>::type>
                                                                           ^
prog.cpp:4:83: error: template argument 1 is invalid
     template<typename U = typename std::enable_if<std::is_floating_point<U>::value>::type>
                                                                                   ^
prog.cpp:11:68: error: 'U' was not declared in this scope
     template<typename U = typename std::enable_if<std::is_integral<U>::value>::type>
                                                                    ^
prog.cpp:11:69: error: template argument 1 is invalid
     template<typename U = typename std::enable_if<std::is_integral<U>::value>::type>
                                                                     ^
prog.cpp:11:77: error: template argument 1 is invalid
     template<typename U = typename std::enable_if<std::is_integral<U>::value>::type>
                                                                             ^
prog.cpp:12:17: error: redefinition of 'template<class U> bool is_equal(U, U)'
     static bool is_equal(U left, U right)
                 ^
prog.cpp:5:17: note: 'template<class U> bool is_equal(U, U)' previously declared here
     static bool is_equal(U left, U right)
                 ^
stdout
Standard output is empty