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

2
  • 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: stackoverflow.com/questions/5547852/…) Commented Jan 6, 2016 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. Commented Jan 6, 2016 at 20:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.