Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-02-08 17:03:34


??????? ??????? (but it was actually Dmitry Arkhipov) wrote:
> чт, 8 февр. 2024 г. в 19:11, Andrey Semashev via Boost
> <boost_at_[hidden]>:
> > Template interface parity is useful in cases like this:
> >
> >
> https://github.com/boostorg/container/blob/6e697d796897b32b471b4f074
> 0d
> > caa03d8ee57cc/include/boost/container/string.hpp#L685-L691
> >
> >
> https://github.com/boostorg/container/blob/6e697d796897b32b471b4f074
> 0d
> > caa03d8ee57cc/include/boost/container/string.hpp#L2314-L2316
>
> std::basic_string instead uses this check:
>
> > This overload participates in overload resolution only if
> > std::is_convertible_v<const StringViewLike&,
> > std::basic_string_view<CharT, Traits>> is true and
> std::is_convertible_v<const StringViewLike&, const CharT*> is false.

I prefer to detect StringLike types by checking for T::value_type,
T::traits_type, T::data() and T::size().

That's almost what the range constructor of std::string_view does,
except the check for T::traits_type was not introduced there because
the constructor was made explicit instead.


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