Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-10-31 13:05:44


Olaf van der Spek wrote:
> Hi,
>
> Why does the overload for boost::string_view not work? The std one works.
> Could it be made to work?
>
> #include <boost/algorithm/string.hpp>
> #include <boost/utility/string_ref.hpp>
> #include <boost/utility/string_view.hpp>
> #include <iostream>
> #include <string_view>
>
> int main()
> {
> boost::trim_copy(boost::string_view()); // error
> boost::trim_copy(std::string_view());
> }

std::string_view doesn't work either in C++17; it requires constructor (5) in

https://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view

that was added in C++20.

boost::string_view can be made to work by the addition of a constructor
that takes two pointers to char, like this

https://github.com/boostorg/core/blob/12f5f51427fbc9d27f56e5de002b0008fea420c9/include/boost/core/detail/string_view.hpp#L364-L368


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