mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
completing first/auto.yo
This commit is contained in:
parent
1917e40a5d
commit
f45c1519e8
1 changed files with 2 additions and 11 deletions
|
@ -87,7 +87,7 @@ so tt(int *const &ip4) is defined.
|
|||
|
||||
The tt(auto) keyword can also be used to postpone the definition of a
|
||||
function's return type. The declaration of a function tt(intArrPtr) returning
|
||||
a pointer to an array of 10 tt(int)s looks like this:
|
||||
a pointer to arrays of 10 tt(int)s looks like this:
|
||||
verb(
|
||||
int (*intArrPtr())[10];
|
||||
)
|
||||
|
@ -107,15 +107,6 @@ any other specification the function might receive (e.g., as a const member
|
|||
A return type specification using tt(auto) is called a
|
||||
emi(late-specified return type).
|
||||
|
||||
The tt(auto) keyword can also be used to defined types that are related to
|
||||
the actual tt(auto) associated type. Here are some examples:
|
||||
verb(
|
||||
vector<int> vi;
|
||||
auto iter = vi.begin(); // standard: auto is vector<int>::iterator
|
||||
auto &&rref = vi.begin(); // auto is rvalue ref. to the iterator type
|
||||
auto *ptr = &iter; // auto is pointer to the iterator type
|
||||
auto *ptr = &rref; // same
|
||||
)
|
||||
|
||||
Since the C++14 standard late return type specifications are no longer
|
||||
required for functions returning tt(auto). Such functions can now simply be
|
||||
|
@ -127,7 +118,7 @@ declared like this:
|
|||
the function declarations:
|
||||
itemization(
|
||||
it() If multiple return statements are used in function definitions they
|
||||
all must be of the same type;
|
||||
all must return values of identical types;
|
||||
it() Functions merely returning tt(auto) cannot be used before the
|
||||
compiler has seen their definitions. So they cannot be used after mere
|
||||
declarations;
|
||||
|
|
Loading…
Reference in a new issue