tmp/tmp24_cnded/{from.md → to.md}
RENAMED
|
@@ -147,11 +147,11 @@ An *unnamed-namespace-definition* behaves as if it were replaced by
|
|
| 147 |
```
|
| 148 |
|
| 149 |
where `inline` appears if and only if it appears in the
|
| 150 |
*unnamed-namespace-definition*, all occurrences of *unique* in a
|
| 151 |
translation unit are replaced by the same identifier, and this
|
| 152 |
-
identifier differs from all other identifiers in the entire program.[^
|
| 153 |
|
| 154 |
``` cpp
|
| 155 |
namespace { int i; } // unique ::i
|
| 156 |
void f() { i++; } // unique ::i++
|
| 157 |
|
|
@@ -205,29 +205,31 @@ namespace R {
|
|
| 205 |
void Q::V::g() { /* ... */ } // error: R doesn't enclose Q
|
| 206 |
}
|
| 207 |
```
|
| 208 |
|
| 209 |
Every name first declared in a namespace is a member of that namespace.
|
| 210 |
-
If a `friend` declaration in a non-local class first declares a class
|
| 211 |
-
function[^
|
| 212 |
-
enclosing namespace. The
|
| 213 |
-
|
| 214 |
-
[[basic.lookup.
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
| 226 |
|
| 227 |
``` cpp
|
| 228 |
-
// Assume f and g have not yet been
|
| 229 |
void h(int);
|
| 230 |
template <class T> void f2(T);
|
| 231 |
namespace A {
|
| 232 |
class X {
|
| 233 |
friend void f(X); // A::f(X) is a friend
|
|
@@ -318,12 +320,12 @@ specified name is so declared; specifying an enumeration name in a
|
|
| 318 |
*using-declaration* does not declare its enumerators in the
|
| 319 |
*using-declaration*’s declarative region. If a *using-declaration* names
|
| 320 |
a constructor ([[class.qual]]), it implicitly declares a set of
|
| 321 |
constructors in the class in which the *using-declaration* appears (
|
| 322 |
[[class.inhctor]]); otherwise the name specified in a
|
| 323 |
-
*using-declaration* is a synonym for
|
| 324 |
-
|
| 325 |
|
| 326 |
Every *using-declaration* is a *declaration* and a *member-declaration*
|
| 327 |
and so can be used in a class definition.
|
| 328 |
|
| 329 |
``` cpp
|
|
@@ -457,14 +459,16 @@ struct X : B {
|
|
| 457 |
using B::i;
|
| 458 |
using B::i; // error: double member declaration
|
| 459 |
};
|
| 460 |
```
|
| 461 |
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
*using-declaration*
|
| 465 |
-
|
|
|
|
|
|
|
| 466 |
|
| 467 |
``` cpp
|
| 468 |
namespace A {
|
| 469 |
void f(int);
|
| 470 |
}
|
|
@@ -526,17 +530,20 @@ void func() {
|
|
| 526 |
struct x x1; // x1 has class type B::x
|
| 527 |
}
|
| 528 |
```
|
| 529 |
|
| 530 |
If a function declaration in namespace scope or block scope has the same
|
| 531 |
-
name and the same parameter
|
| 532 |
-
*using-declaration*, and the declarations do not declare
|
| 533 |
-
function, the program is ill-formed.
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
|
|
|
|
|
|
|
|
|
| 538 |
|
| 539 |
``` cpp
|
| 540 |
namespace B {
|
| 541 |
void f(int);
|
| 542 |
void f(double);
|
|
@@ -559,11 +566,11 @@ void h() {
|
|
| 559 |
When a *using-declaration* brings names from a base class into a derived
|
| 560 |
class scope, member functions and member function templates in the
|
| 561 |
derived class override and/or hide member functions and member function
|
| 562 |
templates with the same name, parameter-type-list ([[dcl.fct]]),
|
| 563 |
cv-qualification, and *ref-qualifier* (if any) in a base class (rather
|
| 564 |
-
than conflicting). For *using-
|
| 565 |
see [[class.inhctor]].
|
| 566 |
|
| 567 |
``` cpp
|
| 568 |
struct B {
|
| 569 |
virtual void f(int);
|
|
@@ -794,11 +801,11 @@ transitive search is unordered. In particular, the order in which
|
|
| 794 |
namespaces were considered and the relationships among the namespaces
|
| 795 |
implied by the *using-directive*s do not cause preference to be given to
|
| 796 |
any of the declarations found by the search. An ambiguity exists if the
|
| 797 |
best match finds two functions with the same signature, even if one is
|
| 798 |
in a namespace reachable through *using-directive*s in the namespace of
|
| 799 |
-
the other.[^
|
| 800 |
|
| 801 |
``` cpp
|
| 802 |
namespace D {
|
| 803 |
int d1;
|
| 804 |
void f(char);
|
|
|
|
| 147 |
```
|
| 148 |
|
| 149 |
where `inline` appears if and only if it appears in the
|
| 150 |
*unnamed-namespace-definition*, all occurrences of *unique* in a
|
| 151 |
translation unit are replaced by the same identifier, and this
|
| 152 |
+
identifier differs from all other identifiers in the entire program.[^5]
|
| 153 |
|
| 154 |
``` cpp
|
| 155 |
namespace { int i; } // unique ::i
|
| 156 |
void f() { i++; } // unique ::i++
|
| 157 |
|
|
|
|
| 205 |
void Q::V::g() { /* ... */ } // error: R doesn't enclose Q
|
| 206 |
}
|
| 207 |
```
|
| 208 |
|
| 209 |
Every name first declared in a namespace is a member of that namespace.
|
| 210 |
+
If a `friend` declaration in a non-local class first declares a class,
|
| 211 |
+
function, class template or function template[^6] the friend is a member
|
| 212 |
+
of the innermost enclosing namespace. The `friend` declaration does not
|
| 213 |
+
by itself make the name visible to unqualified lookup (
|
| 214 |
+
[[basic.lookup.unqual]]) or qualified lookup ([[basic.lookup.qual]]).
|
| 215 |
+
The name of the friend will be visible in its namespace if a matching
|
| 216 |
+
declaration is provided at namespace scope (either before or after the
|
| 217 |
+
class definition granting friendship). If a friend function or function
|
| 218 |
+
template is called, its name may be found by the name lookup that
|
| 219 |
+
considers functions from namespaces and classes associated with the
|
| 220 |
+
types of the function arguments ([[basic.lookup.argdep]]). If the name
|
| 221 |
+
in a `friend` declaration is neither qualified nor a *template-id* and
|
| 222 |
+
the declaration is a function or an *elaborated-type-specifier*, the
|
| 223 |
+
lookup to determine whether the entity has been previously declared
|
| 224 |
+
shall not consider any scopes outside the innermost enclosing namespace.
|
| 225 |
+
The other forms of `friend` declarations cannot declare a new member of
|
| 226 |
+
the innermost enclosing namespace and thus follow the usual lookup
|
| 227 |
+
rules.
|
| 228 |
|
| 229 |
``` cpp
|
| 230 |
+
// Assume f and g have not yet been declared.
|
| 231 |
void h(int);
|
| 232 |
template <class T> void f2(T);
|
| 233 |
namespace A {
|
| 234 |
class X {
|
| 235 |
friend void f(X); // A::f(X) is a friend
|
|
|
|
| 320 |
*using-declaration* does not declare its enumerators in the
|
| 321 |
*using-declaration*’s declarative region. If a *using-declaration* names
|
| 322 |
a constructor ([[class.qual]]), it implicitly declares a set of
|
| 323 |
constructors in the class in which the *using-declaration* appears (
|
| 324 |
[[class.inhctor]]); otherwise the name specified in a
|
| 325 |
+
*using-declaration* is a synonym for a set of declarations in another
|
| 326 |
+
namespace or class.
|
| 327 |
|
| 328 |
Every *using-declaration* is a *declaration* and a *member-declaration*
|
| 329 |
and so can be used in a class definition.
|
| 330 |
|
| 331 |
``` cpp
|
|
|
|
| 459 |
using B::i;
|
| 460 |
using B::i; // error: double member declaration
|
| 461 |
};
|
| 462 |
```
|
| 463 |
|
| 464 |
+
Members added to the namespace after the *using-declaration* are not
|
| 465 |
+
considered when a use of the name is made. Thus, additional overloads
|
| 466 |
+
added after the *using-declaration* are ignored, but default function
|
| 467 |
+
arguments ([[dcl.fct.default]]), default template arguments (
|
| 468 |
+
[[temp.param]]), and template specializations ([[temp.class.spec]],
|
| 469 |
+
[[temp.expl.spec]]) are considered.
|
| 470 |
|
| 471 |
``` cpp
|
| 472 |
namespace A {
|
| 473 |
void f(int);
|
| 474 |
}
|
|
|
|
| 530 |
struct x x1; // x1 has class type B::x
|
| 531 |
}
|
| 532 |
```
|
| 533 |
|
| 534 |
If a function declaration in namespace scope or block scope has the same
|
| 535 |
+
name and the same parameter-type-list ([[dcl.fct]]) as a function
|
| 536 |
+
introduced by a *using-declaration*, and the declarations do not declare
|
| 537 |
+
the same function, the program is ill-formed. If a function template
|
| 538 |
+
declaration in namespace scope has the same name, parameter-type-list,
|
| 539 |
+
return type, and template parameter list as a function template
|
| 540 |
+
introduced by a *using-declaration*, the program is ill-formed. Two
|
| 541 |
+
*using-declaration*s may introduce functions with the same name and the
|
| 542 |
+
same parameter-type-list. If, for a call to an unqualified function
|
| 543 |
+
name, function overload resolution selects the functions introduced by
|
| 544 |
+
such *using-declaration*s, the function call is ill-formed.
|
| 545 |
|
| 546 |
``` cpp
|
| 547 |
namespace B {
|
| 548 |
void f(int);
|
| 549 |
void f(double);
|
|
|
|
| 566 |
When a *using-declaration* brings names from a base class into a derived
|
| 567 |
class scope, member functions and member function templates in the
|
| 568 |
derived class override and/or hide member functions and member function
|
| 569 |
templates with the same name, parameter-type-list ([[dcl.fct]]),
|
| 570 |
cv-qualification, and *ref-qualifier* (if any) in a base class (rather
|
| 571 |
+
than conflicting). For *using-declaration*s that name a constructor,
|
| 572 |
see [[class.inhctor]].
|
| 573 |
|
| 574 |
``` cpp
|
| 575 |
struct B {
|
| 576 |
virtual void f(int);
|
|
|
|
| 801 |
namespaces were considered and the relationships among the namespaces
|
| 802 |
implied by the *using-directive*s do not cause preference to be given to
|
| 803 |
any of the declarations found by the search. An ambiguity exists if the
|
| 804 |
best match finds two functions with the same signature, even if one is
|
| 805 |
in a namespace reachable through *using-directive*s in the namespace of
|
| 806 |
+
the other.[^7]
|
| 807 |
|
| 808 |
``` cpp
|
| 809 |
namespace D {
|
| 810 |
int d1;
|
| 811 |
void f(char);
|