====== String_view for objects with a const string field ====== Store a little string in an object which is going to be its name. It can't change its name, so it ought to be const. Prefer not to use std::string - it's heavyweight, and the data ends up on a separate string allocation. struct Str { constexpr Str(std::string_view s) : buf{[&]{ auto buf = std::array{}; std::copy(s.begin(), s.end(), buf.data()); return buf; }()}, sv{buf.data()} {} std::array const buf; std::string_view const sv; };