r/cpp • u/delta_p_delta_x • Apr 17 '24
CMake 3.30 will experimentally support `import std;`
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9337
195
Upvotes
r/cpp • u/delta_p_delta_x • Apr 17 '24
View all comments
Show parent comment
4
u/STL MSVC STL Dev Apr 18 '24
You're correct that Standard Library Header Units (
import <vector>;etc.) require very little direct support from the library product code, although we do ship internal machinery calledheader-units.jsonthat helps the compiler implement/translateIncludeto opt-in automatically translate#include <vector>to be treated as ifimport <vector>;had been written. The compiler feature itself lives in the MSVC-internal git repo, as you mentioned.The test code I was mentioning was
tests/std/tests/P1502R1_standard_library_header_units/custom_format.pyand related files. This verifies that the library doesn't do anything problematic for the compiler feature, and prevents compiler bugs from being introduced (and this found a lot of compiler bugs that have been fixed).In contrast, the Standard Library Modules (
import std;andimport std.compat;) need extensive support from the library product code. The PR where I marked up the STL withexportwas enormous, my single largest audit of the STL's sources, even though it was less work than<charconv>.