fork(1) download
  1. #include <iostream>
  2. #include <limits>
  3. #include <type_traits>
  4.  
  5. using namespace std;
  6.  
  7. template <typename T, typename = void>
  8. constexpr int foo[] = { 1, 2 };
  9.  
  10. template <typename T>
  11. constexpr int foo[]<T, enable_if_t<is_floating_point<T>::value> = { 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:20: error: expected initializer before ‘<’ token
 constexpr int foo[]<T, enable_if_t<is_floating_point<T>::value> = { 10, 20, 30 };
                    ^
stdout
Standard output is empty