In Rust this is done using Cargo (the build system) and each crate (library / binary) can choose a compiler edition that gates certain features which are not backward compatible.
You can use (depend on) a crate from your code that uses an old edition.
In C++, your idea would require enforcement at the compiler level but the linker should still link both "old" and "new" C/C++ together. Then the switch is done on a .cpp file (translation unit) level.
However the culture around C / C++ compiler development with standards and multiple compilers would require huge committees to decide what is "modern C++." There might be a lot of debate.
Much of the innovation in Python, C# and Rust is in how the process of language and standard library development is managed in the community. I wonder if C++ could do that?
You can use (depend on) a crate from your code that uses an old edition.
In C++, your idea would require enforcement at the compiler level but the linker should still link both "old" and "new" C/C++ together. Then the switch is done on a .cpp file (translation unit) level.
However the culture around C / C++ compiler development with standards and multiple compilers would require huge committees to decide what is "modern C++." There might be a lot of debate.
Much of the innovation in Python, C# and Rust is in how the process of language and standard library development is managed in the community. I wonder if C++ could do that?