0
template<typename T,T default_value=T{}>
class Vec{};

Vec<string,"abc"> vs;

I get an error: 'class std::basic_string' is not a valid type for a template non-type parameter

Milo Lu
  • 3,176
  • 3
  • 35
  • 46
  • They are called "non-type template parameters", which should help you find further info about them more easily. (BTW, string literals aren't allowed either: http://stackoverflow.com/questions/5547852/string-literals-not-allowed-as-non-type-template-parameters) – Mat Jan 06 '16 at 20:28
  • The answer is confusing. I understand a string literal is not acceptable as a template argument. However, the code is from "the c++ programming language" -- Bjarne Stroustrup, Ch25.2.2 values as arguments. Check it out. – Milo Lu Jan 06 '16 at 20:44

0 Answers0