Open
Description
What do you think about the following idea: add a preprocessor macro that replaces content of the header with import std;
if the macro is defined by user.
For example libcxx/include/vector can be changed in the following way:
#ifndef _LIBCPP_VECTOR
#define _LIBCPP_VECTOR
#if defined(LIBCPP_IMPLICIT_MODULES_USE)
import std;
# include <version>
#else
... // all the remaining code from <vector>
#endif // LIBCPP_IMPLICIT_MODULES_USE
#endif // _LIBCPP_VECTOR
Motivation:
- Implicit
import std;
in standard library header would improve compile times if module std is available. - Migration from includes to
import std;
for big projects is not trivial. The above approach eases that migration - It's a possible alternative solution to [C++23] [Modules] [std module] Skip including standard headers if the std module is imported #80663