@@ -32,6 +32,12 @@ The ISO C++ standard follows the valid *expressions* approach, which shows what
3232It has the drawback of relegating important details to notational conventions. This document mostly uses
3333pseudo-signatures because they are concise and can be cut-and-pasted for an initial implementation.
3434
35+ A pseudo-signature describes how an implementation interacts with a type or a function.
36+ A real function signature (after template instantiation, if applicable) may differ from the pseudo-signature
37+ that it implements in ways where implicit conversions would deal with the difference,
38+ transforming function parameter types from the ones in the pseudo-signature to the real signature,
39+ and transforming the actual return value type to the one in the pseudo-signature.
40+
3541For example, the table below shows pseudo-signatures for a *sortable * type ``T ``:
3642
3743---------------------------------------------------------------------------------------------
@@ -40,27 +46,26 @@ For example, the table below shows pseudo-signatures for a *sortable* type ``T``
4046
4147.. cpp :function :: bool operator <(const T& x, const T& y)
4248
43- Compare x and y .
49+ Compare `` x `` and `` y `` .
4450
4551.. cpp :function :: void swap (T& x, T& y)
4652
47- Swap x and y .
53+ Swap `` x `` and `` y `` .
4854
4955---------------------------------------------------------------------------------------------
5056
51- A pseudo-signature describes how an implementation interacts with a type or a function.
52- A real signature (after template instantiation, if applicable) may differ from the pseudo-signature
53- that it implements in ways where implicit
54- conversions would deal with the difference: its function parameter types need to implicitly convert
55- from the ones in the pseudo-signature, and the return value type needs to implicitly convert to the one
56- in the pseudo-signature.
57-
5857For an example type ``U ``, the real signature that implements ``operator< `` in the table above
5958can be expressed as ``int operator<( U x, U y ) ``, because C++ permits implicit conversion from
6059``int `` to ``bool ``, and implicit conversion from ``const U& `` to ``U `` if the type is copy-constructible.
6160For a counter-example, the real signature ``bool operator<( U& x, U& y ) `` is not acceptable
62- because C++ does not permit implicit removal of a ``const `` qualifier from a type, and so the code
63- would not compile if the implementation attempts to pass a const object to the function.
61+ because C++ does not permit implicit removal of the ``const `` qualifier from a type, and so the code
62+ would not compile if the implementation attempts to pass a constant object to the function.
63+
64+ Besides pseudo-signatures, semantic requirements also need to be met by real types and functions.
65+ For example, while ``std::pair<U,U> swap(U x, U y) `` fits the pseudo-signature for *Sortable *
66+ via implicit conversion of references to values and implicit drop of the returned value
67+ (ignored by a library implementation), it is unable to swap the actual variables passed to the function
68+ and therefore does not meet the semantic requirements of *Sortable *.
6469
6570Algorithms
6671----------
0 commit comments