Skip to content

boost::core::string_view gives ambiguous error #167

Open
@Spongman

Description

@Spongman

(1.84 gcc 13.2)

upgrading boost from 1.75 to 1.84 breaks existing code that boils down to:

#include <boost/core/detail/string_view.hpp>

struct Foo
{
	Foo(std::string_view f) {}
	Foo(const std::string& f) {}
};

int main() {
	Foo{std::string_view()};         // works
	Foo{boost::core::string_view()}; // fails

	//Foo{boost::beast::http::fields{}.find("")->value()}; // same failure, works in 1.75
}

https://godbolt.org/z/8TKfP6Pj8

<source>: In function 'int main()':
<source>:11:39: error: call of overloaded 'Foo(<brace-enclosed initializer list>)' is ambiguous
   11 |         Foo{boost::core::string_view()};
      |                                       ^
<source>:6:9: note: candidate: 'Foo::Foo(const std::string&)'
    6 |         Foo(const std::string& f) {}
      |         ^~~
<source>:5:9: note: candidate: 'Foo::Foo(std::string_view)'
    5 |         Foo(std::string_view f) {}
      |         ^~~
Compiler returned: 1

it used to work with BOOST_BEAST_USE_STD_STRING_VIEW. how do I get it to use std::string_view like before?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions