If we have not previously told the compiler that the friend is a template, then the compiler will infer that the friend is an ordinary nontemplate class or function.
如果没有事先告诉编译器该友元是一个模板,则编译器将认为该友元是一个普通非模板类或非模板函数。 (查看原文)
A friend declaration introduces the named class or nonmember function into the surrounding scope. Moreover, a friend function may be defined inside the class. The scope of the function is exported to the scope enclosing the class definition.
友元声明将已命名的类或非成员函数引入到外围作用域中。此外,友元函数可以在类的内部定义,该函数的作用域扩展到包围该类定义的作用域。 (查看原文)
to make a member function a friend, the class containing that member must have been defined.
必须先定义包含成员函数的类,才能将成员函数设为友元。
When we want to restrict friendship to a specific instantiation, then the class or function must have been declared before it can be used in a friend declaration
想要限制对特定实例化的友元关系时,必须在可以用于友元声明之前声明类或函数 (查看原文)
We can think of a strict weak ordering as “less than”
• Two keys cannot both be “less than” each other; if k1 is “less than” k2, then k2 must never be “less than” k1. (查看原文)
Unlike using declarations for ordinary members, a constructor using declaration does not change access level of the inherited constructor(s).
More over, a using declaration can't specify explicit or constexpr, the inherited constructor has the same property as the corresponding base constructor. (查看原文)
An inherited constructor is not treated as a user-defined constructor. Therefore, a class that contains only inherited constructors will have a synthesized default constructor. (查看原文)
array<int, 10> a1 = {0,1,2,3,4,5,6,7,8,9};
array<int, 10> a2 = {0}; // elements all have value 0
a1 = a2; // replaces elements in a1
a2 = {0}; // error: cannot assign to an array from a braced list (查看原文)
Classes generated from a lambda expression have a deleted default constructor, deleted assignment operators, and a default destructor. Whether the class has a default or deleted copy/move constructor depends in the usual ways on the types of the captured data members. (查看原文)
1. Candidate functions: identifies the set of overloaded functions considered for the call.
2. Viable functions: select from the set of candidate functions those functions that can be called with the arguments in the given call.
3. Best Match: determines which viable function provide the best match for the call. (查看原文)
There is an overall best match if there is one and only one function for which
* The match for each argument is no worse than the match required by any other viable function.
* There is at least one argument for which the match is better than the match provided by any other viable function. (查看原文)
Unlink what happens to parameters that have function type, the return type is not automatically converted to a pointer type. We must explicitly specify that the return type is a pointer type. (查看原文)
In an abstract data type, the class designer worries about how the class is implemented. Programmers who use the class need not know how the type works. They can instead think abstractly about what the type does. (查看原文)
A well designed class has an interface that is intuitive and easy to use and has an implementation that is efficient enough for its intended use. (查看原文)
The "= default" can appear with the declaration inside the class body or on the definition outside the class body.
Like any other function, if the "= default" appears inside the class body, the default constructor will be inlined; if it appears on the definition outside the class, the member will not be inlined by default. (查看原文)
Parameters and return type of a constexpr function must be literal types.
Unlike other classes, classes that are literal types may have function members that are constexpr.
An aggregate class whose data members are all of literal type is a literal class.
A nonaggregate class, that meets the following restrictions, is also a literal class.
* The data members all must have literal type.
* The class must have at least one constexpr constructor.
* If a data member has an in-class initializer, the initializer for a member of build-in type must be a constant expression, or if the member has class type, the initializer must use the member's own constexpr constructor.
* The class must use default definition for its destructor. (查看原文)