ARTICLE AD BOX
Assume there are two translation units that differ only in the name of one namespace: aggregator_1 vs. aggregator_2:
// Translation unit 1 namespace a { struct Point { int x; int y; }; } // namespace a namespace aggregator_1 { // <-- This namespace is different using ::a::Point; } // namespace aggregator_1 namespace b { using namespace aggregator_1; struct Line { Point begin; Point end; }; } // namespace band
// Translation unit 2 namespace a { struct Point { int x; int y; }; } // namespace a namespace aggregator_2 { // <-- This namespace is different using ::a::Point; } // namespace aggregator_2 namespace b { using namespace aggregator_2; struct Line { Point begin; Point end; }; } // namespace b1. Does the definition of b::Line in these translation units violate ODR? Assuming the units are linked together.
2. Would it matter if there was using-directive using namespace a; instead of using-declaration using ::a::Point;?
My opinion is that there's no violation in either case, because they basically consist of the same tokens, and name lookup resolves each name to the same entity. Name lookup takes different trajectories, but that seems irrelevant to ODR. Did I miss something important that could qualify these definitions as a violation?
32.7k60 gold badges83 silver badges121 bronze badges
2,71810 silver badges23 bronze badges
2
