Do you really need a function template? Simple function:
my_string do_something(my_string const& input) { ... }
solves your use case. You can pass my_string or a string literal, or even a list bound to init-init, and everything just works.
Since you need a template for other reasons, you can simply provide an overload for const char arrays:
template <class TString> TString do_something(TString const&) { ... } template <size_t N> my_string do_something(const char (&arr)[N]) { return do_something(my_string{arr, N-1}); }
Note: There is no reason to provide a default value for the TString template TString . It makes no sense to use this default value.
Barry source share