Is there any trick to forbid C macro to be called as a lvalue?
Try this:
#define LEFT(X) ((X)->left+0)
#define RIGHT(X) ((X)->right+0)
#undef LEFT
#undef RIGHT
//template<class T>
inline const node * const LEFT(const node * X) {
return X->left;
}
I'd go with the inline function, but if you want a macro:
#define LEFT(X) (1 ? (X)->left : 0)