[Bug libstdc++/68995] New: Including both <tr1/functional> and <functional> can cause ADL problems in std::function SFINAE
rs2740 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Dec 20 07:29:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68995
Bug ID: 68995
Summary: Including both <tr1/functional> and <functional> can
cause ADL problems in std::function SFINAE
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: rs2740 at gmail dot com
Target Milestone: ---
Repro adapted from http://stackoverflow.com/q/34334735/2756719:
#include <tr1/memory>
#include <functional>
#include <tr1/functional>
std::tr1::shared_ptr<int> test() { return {}; }
std::function<std::tr1::shared_ptr<int>()> func = test;
This compiles iff the #include <tr1/functional> is commented out. When both
<functional> and <tr1/functional> are included, however, we get an error,
apparently because
template<typename _Functor>
using _Invoke = decltype(__callable_functor(std::declval<_Functor&>())
(std::declval<_ArgTypes>()...) );
in std::function does an unqualified call to __callable_functor, and picks up
both std::__callable_functor in <functional> from normal unqualified lookup,
and std::tr1::__callable_functor in <tr1/functional> from ADL, resulting in an
ambiguity, which in turn causes substitution failure in the converting
constructor template.
More information about the Gcc-bugs
mailing list