I have many classes/methods like this:
template<typename CharT, typename TraitsT = std::char_traits<CharT> >
struct Foo
{
std::basic_string<CharT, TraitsT> getFoo(void) const
{
return "Foo"; // + this->member_var1 + this->member_var2...
}
};
But depending on CharT, I have to use “”, L””, u”” or “U” (for char, wchar_t, u16char_t, u32char_t).
What syntax must be used to create strings that are independed from such template arguments?
Do you really need the different literals, or can you use the iterator constructor?
Maybe with something a bit more robust than “3” in there, if you’re worried about ease of changing the literal in future.
In response to the point that this isn’t very nice, what about:
Then you have:
If you really need the different literal, then the only thing I’ve thought of so far is to create traits for it, which is really horrible: