friend declaration of a template function of a template class

The following compiles except for the line commented out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct A {
	template <int> void foo() {}
};

template <typename, typename>
struct B {
	void foo() {}
	template <int> void bar() {}
};

class C {
	template <int> friend void A::foo();
	template <typename T, typename U> friend void B<T,U>::foo();
//	template <int> template <typename T, typename U> friend void B<T,U>::bar();
};


How to make that friend declaration?
AFAIK, the friend declaration ought to be:
template <typename T, typename U> template <int N> friend void B<T,U>::bar();

Only g++ accepts it without complaint.

clang++ warns that it does not support it, and turns off all access control for class 'C'
msc++ aborts after discovering an internal error in the compiler.

http://coliru.stacked-crooked.com/a/85073d24f8bae7f7
http://rextester.com/DAN59400
Topic archived. No new replies allowed.