q0987
q0987

Reputation: 35992

error: no matching function for call to set(boost::beast::http::field, std::string_view&)’

boost_1_82_0/boost/beast/core/string_type.hpp:18:1: note: ‘#pragma message: BOOST_BEAST_USE_STD_STRING_VIEW is deprecated, use BOOST_NO_CXX17_HDR_STRING_VIEW instead’
   18 | BOOST_PRAGMA_MESSAGE("BOOST_BEAST_USE_STD_STRING_VIEW is deprecated, use BOOST_NO_CXX17_HDR_STRING_VIEW instead");

Legacy code:
#define BOOST_BEAST_USE_STD_STRING_VIEW

std::string_view my_host;
beast::http::request<http::empty_body> my_request;
my_request.set(http::field::host, my_host);

Updated code: changes made for boost v1.82
#define BOOST_NO_CXX17_HDR_STRING_VIEW    

Now I see the following errors:

error: no matching function for call to ‘boost::beast::http::message<true, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::allocator<char> >
>::set(boost::beast::http::field, std::string_view&)’

Question> What is the best way to adapt the legacy code and migrate it to the v1.82?

Thank you

Upvotes: 1

Views: 295

Answers (1)

sehe
sehe

Reputation: 393769

The switch for string_view types is deprecated, as you already know.

The good news is, it is no longer needed. By dropping the deprecated define (BOOST_BEAST_USE_STD_STRING_VIEW) everything should compile.

The reason is that Beast changed to Boost Core's string_view implementation. This one is interoperable with all common string-view implementations (Boost Utility, Boost Core, boost::string_ref, std::string_view).

Source: I implemented the PR for this change before Boost 1.81

Upvotes: 1

Related Questions