Skip to content

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

@Kojoley

Description

@Kojoley

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions