File: algorithm.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (29 lines) | stat: -rw-r--r-- 1,449 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    The compiler uses the following algorithm to deduce the actual types of
        hi(template type deduction) its template type parameters:
    itemization(
    it() In turn, the function template's parameters are identified using the
arguments of the called function.
    it() For each template parameter used in the function template's parameter
list, the template type parameter is associated with the corresponding
argument's type (e.g., tt(Type) is tt(int) if the argument is tt(int x), and
the function's parameter is tt(Type &value)).
    it() While matching the argument types to the template type parameters,
the three allowed transformations (see section ref(TEMPFUNARGS)) for template
type parameters are applied where necessary.
    it() If identical template type parameters
        hi(template parameters: identical types)
    are used with multiple function parameters, the deduced template types
must exactly match. So, the next function template cannot be called with an
tt(int) and a tt(double) argument:
    verb(template <typename Type>
Type add(Type const &lhs, Type const &rhs)
{
    return lhs + rhs;
})

When calling this function template, two identical types must be used
(albeit that the three standard transformations are of course allowed). If the
template deduction mechanism does not come up with identical actual types for
identical template types, then the function template is not going to be
instantiated.
    )