|
|
От: | Николай Ивченков | |
| Дата: | 30.09.09 09:44 | ||
| Оценка: | |||
struct B;
namespace A {
template <typename T>
void foo(B *) {}
}
struct B {
template<typename T>
friend void A::foo(B *);
};namespace A
{
template <typename T>
void foo(T*) {}
}
struct B
{
template<typename T>
friend void A::foo(B *);
};J>Ну и эта функция, я думаю, инжектируется в объемлющее В пространство имен.When the declarator-id is qualified, the declaration shall refer to a previously declared member of the class or namespace to which the qualifier refers, and the member shall not have been introduced by a using-declaration in the scope of the class or namespace nominated by the nested-name-specifier of the declarator-id.
(случай, когда friend-объявление находится в локальном классе, описан в 11.4/9).If a friend declaration in a non-local class first declares a class or function [footnote 83: this implies that the name of the class or function is unqualified] the friend class or function is a member of the innermost enclosing namespace. The name of the friend is not found by simple name lookup until a matching declaration is provided in that namespace scope (either before or after the class declaration granting friendship). If a friend function is called, its name may be found by the name lookup that considers functions from namespaces and classes associated with the types of the function arguments (3.4.2).
struct X
{
friend void f(X) {}
friend void f(int) {}
};
int main()
{
f(X()); // well-formed: f не находится через unqualified lookup, но находится через ADL
f(0); // ill-formed: f не находится ни через unqualified lookup, ни через ADL
}
|
|
От: |
jazzer
|
Skype: enerjazzer |
| Дата: | 30.09.09 09:48 | ||
| Оценка: | |||
You will always get what you always got
If you always do what you always did