unqualified call to `get<T>` with a non-`boost::optional` type should not match

Open
#90 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start with the minimal C++ reproducer in the issue and inspect the overloads brought in by boost/optional.hpp, comparing qualified and unqualified get calls. Reproduce the failure using the linked Compiler Explorer example; done means the shown unqualified call compiles without trying to instantiate boost::optional.

Written by the indexing model from the issue text.

Description

bug

boost::get<T>(boost::optional<T> ...) overload matches for a non-boost::optional type when boost namespace is associated with argument's type of unqualified call to get<T>.

template <typename U>
struct X {};

template <typename T, typename U>
inline int get(X<U> const&) { return 0; }

namespace boost {
    struct any_type_in_boost_namespace {};
}

#include <boost/optional.hpp>

class tag;

int main()
{
    get<tag>(X<boost::any_type_in_boost_namespace>{});
}

https://godbolt.org/z/14d476

The example obviously should compile, but instead it tries to instantiate boost::optional<tag> and fails the compilation.

Dominant language
C++
Stars
60
Forks
75
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/optional

All issues in boostorg/optional

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.