mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
777b182edd
This allowed me to standardize the sourcetar and sf/* scripts: the base directory (containing ./git) is now empty, except for maintenance scripts, while the source files and build scripts of the annotations are stored in a subdirectory of their own.
24 lines
1 KiB
Text
24 lines
1 KiB
Text
A emi(qualification transformation) adds ti(const) or ti(volatile)
|
|
qualifications to em(pointers). This transformation is applied when the
|
|
function template's type parameter explicitly specifies tt(const) (or
|
|
tt(volatile)) but the function's argument isn't a tt(const) or tt(volatile)
|
|
entity. In that case tt(const) or tt(volatile) is provided by the compiler.
|
|
Subsequently the compiler 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 function template'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). This is then matched against tt(Type const &value) allowing the compiler
|
|
to deduce that tt(Type) must be tt(int).
|