fork download
  1. #include <iostream>
  2.  
  3. template<int i>
  4. struct A
  5. {
  6. //static_assert(false, "");
  7. constexpr static int value = 3;
  8. };
  9.  
  10. template<int i>
  11. struct B
  12. {
  13. constexpr static int value = i * i*i;
  14. };
  15.  
  16. template<int i>
  17. struct CheckVal
  18. {
  19. constexpr static int value = std::conditional<i == 1, B<3>, A<3>>::type::value;
  20. };
  21.  
  22. int main()
  23. {
  24. CheckVal<1> cv;
  25. std::cout << cv.value;
  26. }
Success #stdin #stdout 0s 4512KB
stdin
Standard input is empty
stdout
27