order of importing does affect the outcome!

Reading about C++ 20 modules we find the assertion that the order of importing modules does not matter, and this is always compared with #including headers.
I disagree. The only difference is that macros are not exported and thus text substitution does not occur. And this is a BIG difference, but the order of importing modules does matter if they are at least vaguely related.

To illustrate consider module a1 that declares class Vector and module a2 that declares Vector as an enum class. This will clash the names so we need to resort to namespaces.

Another example please?

Regards,
Juan
JUANDENT wrote:
To illustrate consider module a1 that declares class Vector and module a2 that declares Vector as an enum class.

Isn't this a violation of the One Definition Rule (ODR)?

ODR violations often mean the program is ill-formed, no diagnostic required.

When people say the order of the imports doesn't matter I think they assume the program is well-formed.
Last edited on
the order of importing modules does matter if they are at least vaguely related

That statement implies that when
1
2
3
4
import a1;
import a2;

// ... 

and
1
2
3
4
import a2;
import a1;

// ... 

are both valid programs, the resulting executables are different.

Your "illustration" does not have such example.
Topic archived. No new replies allowed.