C++ Logo

std-discussion

Advanced search

Odr-use

From: Russell Shaw <rjshaw_at_[hidden]>
Date: Thu, 14 Nov 2024 21:07:22 +1100
Hi,

In 14882:2024 at point [A], why is "S::x is not odr-used here" ?

"Odr-use" is not explained well.

------------------------------------------------
6.3 One-definition rule [basic.def.odr]

example 1

In the following example, the set of potential results of the initializer of n
contains the first S::x subexpression, but not the second S::x subexpression.

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 <------ [A]
           : f(S::x); // S::x is odr-used here, so a definition is required
------------------------------------------------

Received on 2024-11-14 10:07:28