GCC reports ../../../../boost/sequence/begin.hpp:53: error: 'begin' is already declared in this scope When creating an overload set by bringing a function into a namespace via using-declaration. Compile the enclosed source to demonstrate.
Created attachment 8939 [details] preprocessed source
Confirmed, reduced testcase (which shows the problem): template <class T> struct t { typedef typename T::type type; }; template<> class t<int>{}; template <class T> struct t1{ }; template<> struct t1<int> { typedef int type; }; namespace name1 { template <class S> typename t<S>::type begin(S const& s); namespace name2 { template <class S> typename t1<S>::type begin(S const& s); } using name2::begin; } /* Test calling the function. */ int f(int a) { return name1::begin(a); } struct aa { typedef double type; }; double g(aa t) { return name1::begin(t); }
*** Bug 26605 has been marked as a duplicate of this bug. ***
This is core issue 565, which has not been addressed by the committe, though John's comment makes sense to me. How important is this issue to SFINAE techniques?
I don't know that SFINAE has anything to do with this. Looks like I was just doing namespace composition.
The names in 26605 make it clearer that it's about SFINAE, but that seems to be what your testcase is trying to do as well: if the compiler accepts the using, you would end up with an ambiguous call except that one of the templates is discarded because only one of the templates has a nested type named "type" for int or double arguments. I don't see any reason why you would want to have multiple templates with the same parameters unless you were using SFINAE to remove all but one of them during the deduction phase of overload resolution.
Mine.
Author: paolo Date: Mon Sep 2 09:42:39 2013 New Revision: 202163 URL: http://gcc.gnu.org/viewcvs?rev=202163&root=gcc&view=rev Log: /cp 2013-09-02 Paolo Carlini <paolo.carlini@oracle.com> PR c++/21682, implement DR 565 * name-lookup.c (compparms_for_decl_and_using_decl): New. (push_overloaded_decl_1, do_nonmember_using_decl): Use it. /testsuite 2013-09-02 Paolo Carlini <paolo.carlini@oracle.com> PR c++/21682, implement DR 565 * g++.dg/template/using24.C: New. * g++.dg/template/using25.C: Likewise. * g++.dg/template/using26.C: Likewise. Added: trunk/gcc/testsuite/g++.dg/template/using24.C trunk/gcc/testsuite/g++.dg/template/using25.C trunk/gcc/testsuite/g++.dg/template/using26.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/name-lookup.c trunk/gcc/testsuite/ChangeLog
Done for 4.9.0.