How to avoid duplication of string literal text in functions that accept different width characters / strings?
I frequently need to create string manipulation functions in C++. My APIs tend to be written to accept std::basic_string<T>
(effectively), but I also want to accept std::basic_string_view<T>
when it makes sense. There have been a few pains in adopting string_view
s which I’ve worked around, but with literals I have found only pain.
C++: How to avoid duplication of string literal text in functions that accept different width characters / strings?
I frequently need to create string manipulation functions in C++. My APIs tend to be written to accept std::basic_string (effectively), but I also want to accept std::basic_string_view when it makes sense. There’ve been a few pains in adopting string_views which I’ve worked around, but with literals I have found only pain.