Is there a concept for a string-like object in standard library? What I mean is something like
template<typename T>
concept StringLike = requires(T x) {
/* is same as const char*, char*, std::string etc */
}
There is a question about handmade Type trait for strings. But I cannot found anything about concepts. Why isn't it included in std?
I was looking for a concept for a function, which accepts only const char*, char* and strings
template<class T>
concept StringLike = std::is_convertible_v<T, std::string_view>;
did the trick for me :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With