File: qualifications.yo

package info (click to toggle)
c%2B%2B-annotations 6.5.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 15,176 kB
  • ctags: 2,567
  • sloc: cpp: 14,411; makefile: 2,988; ansic: 165; perl: 90; sh: 29
file content (23 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
A emi(qualification transformation) adds ti(const) or ti(volatile) qualifications
to em(pointers). This transformation is applied when the template function's
parameter is explicitly defined using a tt(const) (or tt(volatile)) modifier,
and the function's argument isn't a tt(const) or tt(volatile) entity. In that
case, the transformation adds tt(const) or tt(volatile), and subsequently deduces
the template's type parameter. For example:
        verb(
    template<typename Type>
    Type negate(Type const &value)
    {
        return -value;
    }
    int main()
    {
        int x = 5;
        x = negate(x);
    }
        )
    Here we see the template function's tt(Type const &value) parameter: a
reference to a tt(const Type). However, the argument isn't a tt(const int),
but an tt(int) that can be modified. Applying a qualification transformation, the
compiler adds tt(const) to tt(x)'s type, and so it matches tt(int const x)
with tt(Type const &value), deducing that tt(Type) must be tt(int).