C++概念整理

C++ N3797
http://www.open-std.org/JTC1/sc22/wg21/docs/papers/2013/n3797.pdf

# header name preprocessing tokens
p.20
2.9 Header names

p.21 Header name preprocessing tokens

# internal linkage
p.56
3.5 Program and linkage
internal linkage

>An unnamed namespace or a namespace declared directly or indirectly within an unnamed namespace has internal linkage. All other namespaces have external linkage. A name having namespace scope that has not been given internal linkage above has the same linkage as the enclosing namespace if it is the name of
— a variable; or
— a function; or
— a named class (Clause 9), or an unnamed class defined in a typedef declaration in which the class has the typedef name for linkage purposes (7.1.3); or
— a named enumeration (7.2), or an unnamed enumeration defined in a typedef declaration in which the enumeration has the typedef name for linkage purposes (7.1.3); or
— an enumerator belonging to an enumeration with linkage; or
— a template.

# redeclared
3.4.1 Unqualified name lookup
p.46
> In particular, the function parameter names shall not be redeclared in the exception-declaration nor in the outermost block of a handler for the function-try-block.


3.4.4 Elaborated type specifiers
p.54

```
 struct Node {
    struct Node* Next;
    struct Data* Data;
};
  struct Data {
    struct Node* Node;
    friend struct ::Glob;
    friend struct Glob;
/∗ ... ∗/ };
  struct Base {
    struct Data;
    struct ::Data*
    struct Base::Data* thisData;
    friend class ::Data;
    friend class Data;
    struct Data { /* ...  */ };
};
  struct Data;
  struct ::Data;
  struct Base::Data;
  struct Base::Datum;
  struct Base::Data* pBase;
— end example ]
3.4.5 Class member access
// OK: Refers to Node at global scope // OK: Declares type Data
// at global scope and member Data
// OK: Refers to Node at global scope
// error: Glob is not declared
// cannot introduce a qualified type (7.1.6.3) // OK: Refers to (as yet) undeclared Glob // at global scope.
// OK: Declares nested Data // OK: Refers to ::Data
// OK: Refers to nested Data // OK: global Data is a friend // OK: nested Data is a friend // Defines nested Data
// OK: Redeclares Data at global scope
// error: cannot introduce a qualified type (7.1.6.3) // error: cannot introduce a qualified type (7.1.6.3) // error: Datum undefined
// OK: refers to nested Data
```

6.1 Labeled statement
p.129

> The scope of a label is the function in which it appears. Labels shall not be redeclared within a function. 


6.4 Selection statements
p.130

```
if (int x = f()) {
int x;
}
else {
int x;
// ill-formed, redeclaration of x
// ill-formed, redeclaration of x
}
```

7 Declarations
p139

> In such cases, and except for the declaration of an unnamed bit-field (9.6), the decl-specifier-seq shall introduce one or more names into the program, or shall redeclare a name introduced by a previous declaration. [ Example:

```
enum { }; // ill-formed 
typedef class { }; // il l-formed
```
— end example ]




Redeclarations or specializations of a function or function template with a declared return type that uses a
placeholder type shall also use

```
auto f();
auto f() { return 42; } //
that placeholder, not a deduced type. [ Example: return type is int
OK
error, cannot be overloaded with auto f() error, auto and decltype(auto) don’t match
g(T t) { return t; } // #1
// OK, return type is int
// error, no matching template
// OK, forward declaration with unknown return type
template <class T> T g(T t) { return t; } // OK, not functionally equivalent to #1 template char g(char); // OK, now there is a matching template template auto g(float); // still matches #1
void h() { return g(42); } // error, ambiguous
      template <typename T> struct A {
        friend T frf(T);
};
auto frf(int i) { return i; } // not a friend of A<int>
```

— end example ]


7.2 Enumeration declarations
p.156
[Note: This resolves a potential ambiguity between the declaration of an enumeration with an enum-base and the declaration of an unnamed bit-field of enumeration type. [ Example:

```
struct S {
enum E : int {};
enum E : int {}; // error: redeclaration of enumeration
};
```
— end example ] — end note ]


p.157

[ Example:

```
enum { a, b, c=0 };
enum { d, e, f=e+2 };
```
definesa,c,anddtobezero,bandetobe1,andftobe3. —endexample]
3 An opaque-enum-declaration is either a redeclaration of an enumeration in the current scope or a declaration of a new enumeration. 

#function type


3.4.2 Argument-dependent name lookup
p.47
>— If T is a function type, its associated namespaces and classes are those associated with the function parameter types and those associated with the return type.

4.4 Qualification conversions
p.80
> [ Note: Function types (including those used in pointer to member function types) are never cv-qualified (8.3.5). — end note ]


5.2.2 Function call
p.97-p.98
> The postfix expression shall have function type or pointer to function type. For a call to a non-member function or to a static member function, the postfix expression shall be either an lvalue that refers to a function (in which case the function-to-pointer standard conversion (4.3) is suppressed on the postfix expression), or it shall have pointer to function type. Calling a function through an expression whose function type has a language linkage that is different from the language linkage of the function type of the called function’s definition is undefined (7.5).

p.103
>5.2.9 Static cast [expr.static.cast]
 The result of the expression static_cast<T>(v) is the result of converting the expression v to type T. If T is an lvalue reference type or an rvalue reference to function type, the result is an lvalue; if T is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue. The static_cast operator shall not cast away constness (5.2.11).

p.105
5.2.10 Reinterpret cast
>The result of the expression reinterpret_cast<T>(v) is the result of converting the expression v to type T. If T is an lvalue reference type or an rvalue reference to function type, the result is an lvalue; if T is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue and the lvalue-to- rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed on the expression v. 

,

>71) Function types (including those used in pointer to member function types) are never cv-qualified; see 8.3.5.

p.106
> A function pointer can be explicitly converted to a function pointer of a different type. The effect of calling a function through a pointer to a function type (8.3.5) that is not the same as the type used in the definition of the function is undefined. Except that converting a prvalue of type “pointer to T1” to the type “pointer to T2” (where T1 and T2 are function types) and back to its original type yields the original pointer value, the result of such a pointer conversion is unspecified. [ Note: see also 4.10 for more details of pointer conversions. — end note ]

.

>A prvalue of type “pointer to member of X of type T1” can be explicitly converted to a prvalue of a different type “pointer to member of Y of type T2” if T1 and T2 are both function types or both object types.73 The null member pointer value (4.11) is converted to the null member pointer value of the destination type. The result of this conversion is unspecified, except in the following cases:

.

>The result of this conversion is unspecified, except in the following cases:
— converting a prvalue of type “pointer to member function” to a different pointer to member function type and back to its original type yields the original pointer to member value.

p.108
5.3.1 Unary operators
> The unary * operator performs indirection: the expression to which it is applied shall be a pointer to an object type, or a pointer to a function type and the result is an lvalue referring to the object or function to which the expression points. 

p.109
Neither does qualified-id, because there is no implicit conversion from a qualified-id for a non-static member function to the type “pointer to member function” as there is from an lvalue of function type to the type “pointer to function” (4.3). Nor is &unqualified-id a pointer to member, even within the scope of the unqualified-id’s class. — end note ]
5 If & is applied to an lvalue of incomplete class type and the complete type declares operator&(), it is unspecified whether the operator has the built-in meaning or the operator function is called. The operand of & shall not be a bit-field.

### 最後までおよみいただきありがとうございました。
いいね　💚、フォローをお願いします。
####  Thank you very much for reading to the last sentence.
Please press the like icon 💚　and follow me for your happy life.