条款02—— Prefer consts, enums, and inlines to #defines(宁可以编译器替换预处理器)
一、 The enum hack
二、 inline
函数宏:
// 以a和b的较大值调用f
#define CALL_WITH_MAX(a, b) f((a) > (b) ? (a) : (b))
template <typename T> // 由于我们不知道T是什么,所以采用pass by reference to const
inline void callWithMax(const T& a, const T& b)
{
f(a > b ? a : b);
}