A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4140/namespace.memdef below:

[namespace.memdef]

7.3.1.2 Namespace member definitions [namespace.memdef]

Members (including explicit specializations of templates ([temp.expl.spec])) of a namespace can be defined within that namespace. [ Example:

namespace X {
  void f() {  }
}

 — end example ]

Members of a named namespace can also be defined outside that namespace by explicit qualification ([namespace.qual]) of the name being defined, provided that the entity being defined was already declared in the namespace and the definition appears after the point of declaration in a namespace that encloses the declaration's namespace. [ Example:

namespace Q {
  namespace V {
    void f();
  }
  void V::f() {  }       void V::g() {  }       namespace V {
    void g();
  }
}

namespace R {
  void Q::V::g() {  }  }

 — end example ]

Every name first declared in a namespace is a member of that namespace. If a friend declaration in a non-local class first declares a class, function, class template or function template97 the friend is a member of the innermost enclosing namespace. The friend declaration does not by itself make the name visible to unqualified lookup ([basic.lookup.unqual]) or qualified lookup ([basic.lookup.qual]). [ Note: The name of the friend will be visible in its namespace if a matching declaration is provided at namespace scope (either before or after the class definition granting friendship).  — end note ] If a friend function or function template 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 ([basic.lookup.argdep]). If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace. [ Note: The other forms of friend declarations cannot declare a new member of the innermost enclosing namespace and thus follow the usual lookup rules.  — end note ] [ Example:

void h(int);
template <class T> void f2(T);
namespace A {
  class X {
    friend void f(X);               class Y {
      friend void g();                friend void h(int);                                             friend void f2<>(int);        };
  };

    X x;
  void g() { f(x); }              void f(X) { /* ... */}         void h(int) { /* ... */ }      }

using A::x;

void h() {
  A::f(x);
  A::X::f(x);                     A::X::Y::g();                 }

 — end example ]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4