mkm*_*afa 2 c++ one-definition-rule language-lawyer
根据odr-use定义,如果引用与它绑定,则对象使用odr.这就是为什么f使S :: x odr-used我相信.我无法理解的是,与逗号运算符有什么不同,它还将其参数绑定到引用参数
struct S {
static const int x = 0; // static data member
// a definition outside of class is required if it is odr-used
};
const int& f(const int& r);
int n = b ? (1, S::x) // S::x is not odr-used here
: f(S::x); // S::x is odr-used here: a definition is required
Run Code Online (Sandbox Code Playgroud)