0

Suppose I have a function template

template <typename T>
void f(T) {}

Then, we could have a friend declaration

friend void f<int>(int);

and an explicit template instantiation declaration

extern template void f<int>(int);

Are the two declarations related in some way or totally independent? If related, how do they interact with each other?

4

1 回答 1

1

friend声明不与任何事物“交互”,除了声明为友元的函数定义,允许访问包含声明的类的私有成员。

friend所以,不,声明和声明之间没有特殊的交互extern template,尽管它们都引用同一个函数(从这个意义上说,它们是相关的,但我假设你在写问题时意识到了这一点)。

于 2015-10-01T20:53:41.560 回答