---restore content starts---
CONSTEXPR: The modifier constant expression, the contract adornment object not only is the constant, but also can obtain the value in the compilation stage.
Unlike const, CONSTEXPR is bound by the parties, that is, constexpr int *a=1; A pointer itself is a const, and the right is simple enough, and a const int*a; Such a statement contracts A to the object is a const , this is a different point. The constexpr is directly limited to the top-level const.
Type aliases: traditional typedef,
Double1.1;
Code like this means A is a double type
The new C11 standard has a new type alias definition:
Using a = double;
There is a point to note about the type aliases of pointers:
Char *A; Const 0;//cstr is a constant pointer to char Const a *p; P is a pointer to a char constant pointer
If the direct literal substitution is understood, the typedef will get a wrong understanding.
For example, bring in the following code: const char *a = 0; This is the underlying const, and this understanding is wrong.
Auto Type: C11 the type introduced by the new standard. The compiler helps us to determine the type.
Similar to auto a = 1; A is an int type.
It is important to note that:
Const int *a ==constint1= c;
b The result is a pointer to an int constant, and d is just the normal int type.
The compiler discards the top-level const, while the underlying const is preserved.
Similar to:
1, b=2;
Such code, you must ensure that a, and B are the same type.
Otherwise you will get an error.
Decltype Type Indicator
Another indicator of the c++11 new standard is the Decltype type indicator:
Decltype (f ()) sum = x;
It qualifies the type according to the F () return value, which, unlike the top and bottom const, differs from auto, and the const is retained, even the top level.
Such as:
const int i = 0;
Decltype (i) a = 0;
A is also a const int.
The dereference and () expressions will also return a reference at the end.
---restore content ends---
C + + Learning Note 2--constexpr, type alias, auto