struct S { static const int x = 0; }; 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, so a definition is required— end example
void f(int n) { [] { n = 1; }; // error, n is not odr-usable due to intervening lambda-expression struct A { void f() { n = 2; } // error, n is not odr-usable due to intervening function definition scope }; void g(int = n); // error, n is not odr-usable due to intervening function parameter scope [&] { [n]{ return n; }; }; // OK }— end example
struct X; // declare X as a struct type struct X* x1; // use X in pointer formation X* x2; // use X in pointer formation
// translation unit 1: struct X { X(int, int); X(int, int, int); }; X::X(int, int = 0) { } class D { X x = 0; }; D d1; // X(int, int) called by D() // translation unit 2: struct X { X(int, int); X(int, int, int); }; X::X(int, int = 0, int = 0) { } class D { X x = 0; }; D d2; // X(int, int, int) called by D(); // D()'s implicit definition violates the ODR— end example