| High Integrity CPP Rule 14.19 | Do not use function macros, use inline functions instead. |
| (QA C++ 1020) |
| Justification |
Inline functions are as 'efficient' as function macros and have the predictable behaviour and type safety advantages of a regular function.
#define MAX(a,b) ( ( a ) > ( b ) ? ( a ) : ( b ) ) // avoid
template< typename T > // prefer
inline const T& max( const T& a, const T& b )
{
return a > b ? a : b;
}
|
| Exclusive with |
Rule 14.14 |
| See also |
Rule 14.17 |
| Reference |
Effective C++ Item 1;Industrial Strength C++ 13.5; |