30-12-2011, 08:19 PM
The rule states that the types for a function declaration and definition must be token-for-token identical. How literally should this rule be taken. I have two cases where this rule seems to conflict with normal or good practice.
1. In a function definition, a 'const' qualifier is often included for parameters passed by value as a promise that the implementation will not modify these parameters. This qualifier cannot be included in the declaration. For example:
template
T low_bits_mask(unsigned n);
template
T low_bits_mask(const unsigned n) {
return ~((~static_cast(0))
1. In a function definition, a 'const' qualifier is often included for parameters passed by value as a promise that the implementation will not modify these parameters. This qualifier cannot be included in the declaration. For example:
template
T low_bits_mask(unsigned n);
template
T low_bits_mask(const unsigned n) {
return ~((~static_cast(0))
<t></t>