boost::core::string_view gives ambiguous error

Open
#167 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start with the reproducer in the issue and inspect boost/core/detail/string_view.hpp, comparing the Boost 1.75 and 1.84 behavior around BOOST_BEAST_USE_STD_STRING_VIEW. Run the provided GCC 13.2 example to confirm the ambiguous constructor error. Done means the reported string_view construction is no longer ambiguous while preserving the relevant existing behavior, with a regression test covering the example.

Written by the indexing model from the issue text.

Description

(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?

Dominant language
C++
Stars
156
Forks
116
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/core

All issues in boostorg/core

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.