Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[C++20] [Modules] [std module] Implicitly import std if standard library header is included #138906

Copy link
Copy link
Open
@apolukhin

Description

@apolukhin
Issue body actions

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 [C++23] [Modules] [std module] Skip including standard headers if the std module is imported #80663

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:modulesC++20 modules and Clang Header ModulesC++20 modules and Clang Header Moduleslibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.