~ubuntu-branches/ubuntu/trusty/c++-annotations/trusty

« back to all changes in this revision

Viewing changes to yo/first/typeinference.yo

  • Committer: Package Import Robot
  • Author(s): Frank B. Brokken
  • Date: 2012-01-20 11:53:17 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20120120115317-v4wiq9sttx72fabk
Tags: 9.1.0-1
New upstream release (covering C++11 to a large extend)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
A special use of the keyword ti(auto) is defined by the C++0x standard
 
1
A special use of the keyword ti(auto) is defined by the C++11 standard
2
2
allowing the compiler to determine the type of a variable automatically rather
3
3
than requiring the software engineer to define a variable's type explicitly.
4
4
 
5
5
In parallel, the use of tt(auto) as a storage class specifier is no longer
6
 
supported in the C++0x standard. According to that standard a variable
 
6
supported in the C++11 standard. According to that standard a variable
7
7
definition like tt(auto int var) results in a compilation error.
8
8
 
9
9
This can be very useful in situations where it is very hard to determine the
48
48
        )
49
49
 
50
50
    If tt(start) can't be initialized immediately using an existing
51
 
variable the type of a well known variable of function can be used in
 
51
variable the type of a well known variable or function can be used in
52
52
combination with the ti(decltype) keyword, as in:
53
53
        verb(
54
54
    decltype(iter) start;
55
55
    decltype(begin()) spare;
56
56
        )
57
57
    The keyword tt(decltype) may also receive an expression as its
58
 
argument. This feature is already available in the C++0x standard
 
58
argument. This feature is already available in the C++11 standard
59
59
implementation in g++ 4.3. E.g., tt(decltype(3 + 5)) represents an int,
60
60
tt(decltype(3 / double(3))) represents tt(double).
61
61