【发布时间】:2018-10-19 13:34:22
【问题描述】:
根据odr-use defintion,如果引用绑定到对象,则该对象是odr-used。这就是我相信 f 使 S::x odr-used 的原因。我无法理解的是,这与comma operator 有何不同,后者还将其参数绑定到引用参数
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
【问题讨论】:
标签: c++ language-lawyer one-definition-rule