https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61936
Bug ID: 61936
Summary: gcc:g++ template template friends fail to compile.
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: modysk at hotmail dot com
In header view.h
template<class S, template<typename> class V>
void Operate(S c, const V<S>& vx);
template<class T, template<typename> class U>
class ViewBase
{
template<class S, template<typename> class V>
friend void Operate(S c, const V<S>& vx);
};
template<class T>
class ViewTypeA : public ViewBase<T, ViewTypeA>
{
};
template<class T>
class ViewTypeB : public ViewBase<T, ViewTypeB>
{
};
template<class S, template<typename> class V>
void Operate(S c, const V<S>& vx)
{
}
In main.cpp
#include "view.h"
int main(int argc, char **argv)
{
Operate(5, ViewTypeA<int>());
}
gcc (compiling with -std=gnu++11) gives errors
main.cpp||In function ‘int main(int, char**)’:
main.cpp|7|error: call of overloaded ‘Operate(int, ViewTypeA<int>&)’ is
ambiguous
main.cpp|7|note: candidates are:
view.h|25|note: void Operate(S, const V<S>&) [with S = int; V = ViewTypeA]
view.h|9|note: void Operate(S, const V<S>&) [with S = int; V = ViewTypeA; T =
int; U = ViewTypeA]
The ambiguity seems to be based on the _class_ template parameters which should
not come into the picture at all for the user.