Why can’t I use std::string as a non-type template parameter?

The reason you can’t do this is because non-constant expressions can’t be parsed and substituted during compile-time. They could change during runtime, which would require the generation of a new template during runtime, which isn’t possible because templates are a compile-time concept. Here’s what the standard allows for non-type template parameters (14.1 [temp.param] p4): A … Read more