fork 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. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
1