
2 Jun
2015
2 Jun
'15
10:31 a.m.
Louis Dionne wrote:
`constexpr` char arrays and character packs are not equivalent. The problem is that constexpr-ness is stripped away by argument passing. For illustration, consider the following example:
template <typename CompileTimeString> void f(CompileTimeString s) { static_assert(s == "abc", ""); }
constexpr std::string_literal<n> n4121 = "abc"; constexpr auto n4236 = "abc"_s;
f(n4121); // error: s is not constexpr within the body of f f(n4236); // ok: the value of s is contained in its type
I assume that you mean for 'f' to be constexpr?