
30 Nov
2020
30 Nov
'20
12:36 a.m.
Gavin Lambert wrote:
For this specific use, it doesn't need to. It can just match against a StringLike concept, as I said.
Except that you can't use concepts in a compiled library, only in a header-only one. (Or it still requires you to write that concrete type conversion.)
Of course you can. class string_view { public: template<class StringLike, class E = enable_if_t<is_string_like<StringLike>> > string_view( StringLike const& sl ): p_( sl.data() ), n_( sl.size() ) {} }; void my_compiled_library( string_view sv ); This is not something theoretical. E.g. Victor Zverovich has independently come to the same conclusion: https://twitter.com/vzverovich/status/1333111364357746690