fork download
  1. #include <iostream>
  2. #include <limits>
  3. #include <type_traits>
  4.  
  5. using namespace std;
  6.  
  7. template <typename T>
  8. constexpr enable_if_t<is_integral<T>::value, int[]> foo = { 1, 2 };
  9.  
  10. template <typename T>
  11. constexpr enable_if_t<is_floating_point<T>::value, int[]> foo = { 10, 20, 30 };
  12.  
  13.  
  14. int main() {
  15. cout << foo<int>[0] << endl;
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:11:59: error: redeclaration of ‘template<class T> constexpr std::enable_if_t<std::is_floating_point<_Tp>::value, int []> foo’
 constexpr enable_if_t<is_floating_point<T>::value, int[]> foo = { 10, 20, 30 };
                                                           ^~~
prog.cpp:8:53: note: previous declaration ‘template<class T> constexpr std::enable_if_t<std::is_integral<_Tp>::value, int []> foo<T>’
 constexpr enable_if_t<is_integral<T>::value, int[]> foo = { 1, 2 };
                                                     ^~~
stdout
Standard output is empty