Add conversions from and to boost::string_view

This commit is contained in:
Peter Dimov
2021-12-18 03:28:17 +02:00
parent 02b3f91fc3
commit 7a79d17da2
6 changed files with 60 additions and 2 deletions

View File

@@ -34,6 +34,9 @@
namespace boost
{
template<class Ch, class Tr> class basic_string_view;
namespace core
{
namespace detail
@@ -388,6 +391,11 @@ public:
#endif
template<class Ch2> basic_string_view( boost::basic_string_view<Ch2, std::char_traits<Ch2> > const& str,
typename boost::enable_if<is_same<Ch, Ch2> >::type* = 0 ) BOOST_NOEXCEPT: p_( str.data() ), n_( str.size() )
{
}
// BOOST_CONSTEXPR basic_string_view& operator=( basic_string_view const& ) BOOST_NOEXCEPT & = default;
// conversions
@@ -407,6 +415,12 @@ public:
#endif
template<class Ch2> operator boost::basic_string_view<Ch2,
typename boost::enable_if<boost::core::is_same<Ch2, Ch>, std::char_traits<Ch> >::type> () const BOOST_NOEXCEPT
{
return boost::basic_string_view< Ch, std::char_traits<Ch> >( data(), size() );
}
// iterator support
BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT