Lets consider this kind of template:
template<typename CharT>
std::basic_string<CharT> refEnvVaraiable(const std::basic_string<CharT> &varaibleName)
{
std::basic_string<CharT> result;
result.reserve(varaibleName.length() + 3);
result = "${" + varaibleName + "}";
return result;
}
Plan is that this suppose to handle strings with any character size.
This of course will not compile if argument function argument is std::wstring
since there is no operator to concat it with string literal of type const char[]
.
How to force string literal to match desired character type? Do I have to provide specializations for constants representing literals (this lots of boiler plate code)? Or is there a ready tool for it?