Issue 138906
Summary [C++20] [Modules] [std module] Implicitly import std if standard library header is included
Labels new issue
Assignees
Reporter apolukhin
    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:
1. Implicit `import std;` in standard library header would improve compile times if module std is available.
2. Migration from includes to `import std;` for big projects is not trivial. The above approach eases that migration
3. It's a possible alternative solution to https://github.com/llvm/llvm-project/issues/80663
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to