Opened 6 years ago

Last modified 6 years ago

#12917 new Bugs

string_ref not constructible from rvalue strings anymore

Reported by: Mathias Gaunard Owned by: Marshall Clow
Milestone: To Be Determined Component: utility
Version: Boost 1.64.0 Severity: Regression
Keywords: Cc:

Description

The change introduced in this commit is a regression https://github.com/boostorg/utility/commit/9960d9f395b79ee860e39064cd46961f76d2cb55

This breaks user code and is inconsistent with std::string_view. It is therefore undesirable.

Change History (4)

comment:1 by Marshall Clow, 6 years ago

Can you please give an (non-contrived) example of user code that is broken by this?

comment:2 by arvid.norberg@…, 6 years ago

one example of this from my project:

std::string combine_path(string_view left, string_view right);

It used to be possible to nest these, like this:

auto a = combine_path(foo, combine_path(bar, b));

in boost-1.64 this is no longer possible, a proposed work-around is to introduce a string_view make_sv(std::string const&) function, to turn the temporary into an lvalue and construct the string_view from that. https://github.com/arvidn/libtorrent/pull/1814

comment:3 by Marshall Clow, 6 years ago

thanks for the example. The change was made in response to https://svn.boost.org/trac/boost/ticket/11740. "string_ref not working correctly with rvalue of std::string"

comment:4 by olafvdspek@…, 6 years ago

https://github.com/mclow/String-Algo/issues/8

return db.query(make_query(db, q, a...));

make_query returns string, db.query takes string_view.

Note: See TracTickets for help on using tickets.