Question Details

No question body available.

Tags

c++ namespaces language-lawyer c++20 one-definition-rule

Answers (1)

March 5, 2026 Score: 4 Rep: 42,494 Quality: Medium Completeness: 50%

The relevant rule ([basic.def.odr]/16.4) is that

In each such definition, corresponding names, looked up according to [basic.lookup], shall denote the same entity, after overload resolution ([over.match]) and after matching of partial template specializations[…]

So not only is your example OK, but you can even have different lookup results so long as the declaration you actually use is the same in each case. (There is a further exceptions for pre-inline constants, as well as further restrictions on language linkage, etc.)