fork download
  1. #include <iostream>
  2.  
  3. template <bool>
  4. struct value_chooser;
  5.  
  6. template<>
  7. struct value_chooser<true>
  8. {
  9. static constexpr auto value = "str47";
  10. };
  11.  
  12. template<>
  13. struct value_chooser<false>
  14. {
  15. static constexpr auto value = 47;
  16. };
  17.  
  18. int main()
  19. {
  20. auto value1 = value_chooser<true>::value;
  21. auto value2 = value_chooser<false>::value;
  22.  
  23. std::cout << value1 << "-" << value2 << std::endl;
  24. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
str47-47