Boost logo

Boost :

From: Gavin Lambert (boost_at_[hidden])
Date: 2020-11-30 01:32:08


On 30/11/2020 1:36 pm, Peter Dimov wrote:
> 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 );

Yes, that's exactly what I meant by "concrete type conversion".

Since the standard library string_view doesn't (currently?) do this, it
means that everybody will be writing their own string_views. (Or worse:
writing their own is_string_like.) This is not an improvement.

> Victor Zverovich has independently come to the same conclusion:
> https://twitter.com/vzverovich/status/1333111364357746690

I'm not sure if that was the wrong link or if you're referring to
something non-obvious to me there, but that doesn't appear related.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk