搞破鞋是什么意思| 沄字五行属什么| 色令智昏是什么意思| 不解之谜的意思是什么| 坐月子能吃什么菜| 慢性肠炎有什么症状| 蜂王浆是什么东西| 什么叫牙冠| 什么之交| 胃气上逆吃什么中成药| 梦见缝被子是什么意思| 长期失眠挂什么科| 徐才厚什么级别| 怀孕初期头晕是什么原因| 睡莲和碗莲有什么区别| 建档立卡是什么意思| 耐药是什么意思| 老人头晕挂什么科| 梦到借钱给别人什么意思| 纯净水是什么水| 眼神迷离是什么意思| 什么样的晚霞| 低血糖的人吃什么东西最好| 白猫是什么品种| 小蜘蛛吃什么| 离子四项是检查什么的| 螨虫什么样子| 摇头晃脑是什么生肖| 尿路感染要吃什么药| 子欲养而亲不待什么意思| 尘字五行属什么| 富不过三代是什么意思| 什么东西| 0是什么意思网络语言| 虱子长什么样子图片| 享受低保需要什么条件| 过敏不能吃什么东西| 头发不干就睡觉有什么危害| 为什么会得心脏病| 鬼压床是什么原因| 50年是什么婚| 平方是什么意思| 男占258女占369什么意思| 维生素b3又叫什么| 酉什么意思| 手脱皮吃什么药| 圆圆的月亮像什么| 欧了是什么意思| 马可以加什么偏旁| 唐山大地震是什么时候| 不甘心是什么意思| 43岁属什么| 教师节属什么生肖| 曌是什么意思| 胆囊炎挂什么科| 水光针是什么| 八点半是什么时辰| 扁桃体炎吃什么药最好效果好| 男人遗精是什么原因| 甾体是什么意思| o型血和b型血的孩子是什么血型| 向左向右向前看是什么歌| 榴莲什么人不适合吃| 令香是什么意思| 美国为什么打伊拉克| 什么是躯体化症状表现| 申时属什么| 不能生育的女人有什么特征| 防晒衣什么颜色最防晒| hpv是一种什么病| 流星是什么| ooc是什么意思| 梦到拔牙是什么预兆| 肝郁脾虚吃什么药效果最好| b票能开什么车| 宫颈出血是什么原因| 胡萝卜含有什么维生素| 黄豆酱做什么菜好吃| 骨折什么症状| 性取向是什么意思| 月经突然停止是什么原因| 什么不安成语| 古曼童是什么| 浣熊吃什么食物| 全血检查能查些什么病| 梅长苏结局是什么| 心里发慌什么原因| 绦是什么意思| 增大摩擦力的方法有什么| 象牙带身上有什么好处| 高考三百多分能上什么学校| gpr是什么意思| 有样学样是什么意思| 编程是干什么的| 贫血是什么原因导致的| 念力是什么意思| 智齿肿痛吃什么药| 碧螺春是什么茶| modal是什么意思| 做爱时间短吃什么药好| 西安有什么特色美食| 解禁是什么意思| 抗核抗体弱阳性说明什么| 0x00000024蓝屏代码是什么意思| 东方不败练的什么武功| 福星高照是什么生肖| 心属于五行属什么| 宦游人是什么意思| 敏是什么意思| 尿蛋白高是什么病| 百草枯什么味道| 国家一级演员是什么级别| lee是什么牌子| 痛风吃什么好| 午时右眼跳是什么预兆| 减脂吃什么主食| 什么山什么水| 1月3日什么星座| mmi是什么药| 耳朵热是什么原因| mri检查是什么| 平光眼镜是什么意思| 肺热咳嗽吃什么药| 湿气重会有什么症状| 522是什么意思| 保胎吃什么食物好| 杏仁有什么好处| 没谁了是什么意思| 老年斑是什么原因引起的| 2015属什么生肖| 梦见屎是什么意思| 葸是什么意思| 什么眉什么目| 木克什么| 手冲是什么意思| essential是什么意思| 止鼾什么方法最有效| 尘肺病吃什么能排出尘| 为什么女生喜欢腹肌| 91年的属什么生肖| 大什么什么针| 去冰和常温有什么区别| 塔罗牌逆位是什么意思| 网络拒绝接入什么意思| afp检查是什么意思| 今天什么年| 星字属于五行属什么| 浅表性胃炎什么症状| cin3是什么意思| 1954属什么生肖| 什么水果助消化| 梦见猫咬我是什么意思| 西米露是什么| 已读不回是什么意思| 七月二号是什么日子| 什么时候吃榴莲最好| ect是什么意思| 肺部条索影是什么意思| 大红色配什么颜色好看| 皇后是什么意思| 回奶吃什么快最有效的| 拉拉裤和纸尿裤有什么区别| 孕期同房需要注意什么| 北京大栅栏有什么好玩的| 五岳是什么意思| 霞字五行属什么| 锰酸钾是什么颜色| swell是什么牌子| 三月24号是什么星座的| 基因突变是什么意思| 然五行属什么| 什么是海拔| 梦见一条大蟒蛇是什么征兆| 铁线虫是什么| 咳黄痰吃什么药好得快| 72年五行属什么| 炉果是什么| ems什么意思| 三顾茅庐的顾是什么意思| 什么样的月亮| 省纪委副书记是什么级别| 水牛是什么意思| cima是什么证书| 27属相是什么生肖| 肾阴虚是什么意思| 定坤丹适合什么人吃| 腹部胀疼是什么原因| 广东第一峰叫什么山| 生理期为什么不能拔牙| 鸟加一笔是什么字| 什么是反物质| 刘秀和刘邦是什么关系| cav是什么意思| 最近有什么病毒感染| 红蓝是什么意思| dpa是什么意思| 可孚属于什么档次| 若无其事的若是什么意思| 谷氨酸高是什么原因| 紧急避孕药有什么副作用| 石英表不走了是什么原因| 天铁是什么| 咳嗽不停是什么原因| ojbk什么意思| 16岁可以做什么工作| 乙肝没有抗体是什么意思| 印堂跳动是什么预兆| 嗜的意思是什么| 滞后是什么意思| 企业hr是什么意思| 测尿酸挂什么科| 十年结婚是什么婚| 什么是化学| 小儿风寒感冒吃什么药最好| 蚊子的天敌是什么| b型血为什么招蚊子| 女人手指粗短是什么命| 肝脏钙化灶什么意思| 破伤风疫苗什么时候打| 什么的哲理| 人棍是什么意思| 不排卵是什么原因| 9月9号是什么星座| 小孩什么时候会说话| 肾素低说明什么| 肺结核咳血是什么程度| 什么将什么相| 颈椎病头晕吃什么药好| 低筋面粉可以用什么代替| 性激素是什么意思| 头皮疼是什么原因| 无利不起早是什么意思| 白芷有什么作用与功效| 炖牛肉放什么佐料| 身上起痘痘是什么原因| 一天中什么时候最冷| 君子兰什么时候开花| 慈禧为什么要毒死光绪| 10月16日什么星座| 从来不吃窝边草是什么生肖| 烤鱼一般用什么鱼| 什么是膳食纤维| 你想吃什么| 为什么眼皮会跳| 淋巴是什么引起的| 牛郎是什么职业| 脸水肿是什么原因| 榴莲壳有什么用处| 有血流信号是什么意思| min是什么单位| 肝ca什么意思| 心脏早搏什么症状| 卵巢早衰吃什么药| 5月15日什么星座| 大便干燥吃什么药| 鹅口疮是什么原因引起的| 吃什么水果变白| 什么地跑步| 车厘子和樱桃什么区别| 宫颈糜烂用什么药| 左后背疼什么原因| 营养性贫血是什么意思| 但微颔之的之是什么意思| 什么时候敷面膜是最佳时间| 百度Jump to content

懂车的人只买三种保险,别再年年花那个冤枉钱

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Caleb Stanford (talk | contribs) at 19:54, 25 July 2025 (Declining submission: Thanks for the work on the article! The text is looking pretty good, can you address the following? 1) Please add inline citations to the remaining sentences missing citations. Loo...). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
  • Comment: (In response) I have reworded many parts of the article to be less essay-like and added official ISO C++ specification citations wherever applicable, I think it is adequately sourced now. 24.50.56.74 (talk) 23:17, 24 July 2025 (UTC)
  • Comment: Some large sections of unsourced text. Encoded  Talk ?? 22:01, 26 June 2025 (UTC)

百度 健全领导干部、党代表、人大代表、政协委员联系小区制度;驻社区机关、事业单位和国有企业分别联系一家以上住宅小区为友好单位,为联系小区办实事、解难题,并建立以业主(租户)公约为纽带、权责利对等的新型物业管理模式。

Modules in C++ are a feature added in C++20 implementing modular programming as a modern alternative to precompiled headers.[1] A module in C++ comprises a single translation unit. Like header files and implementation files, a module can contain declarations and definitions, but differ from precompiled headers in that they do not require the preprocessor directive #include, but rather are accessed using the word import. A module must be declared using the word module to indicate that the translation unit is a module.[1] A module, once compiled, is stored as a .pcm (precompiled module) file which acts very similar to a .pch (precompiled header) file.[2]

Modules most commonly have the extension .cppm (primarily common within Clang and GCC toolchains), though some alternative extensions include .ixx and .mxx (more common in Microsoft/MSVC toolchains).[3]

Though the standard C language does not have modules, dialects of C allow for modules, such as Clang C.[4] However, the syntax and semantics of Clang C modules differ from C++ modules significantly.

Main uses

Modules provide the benefits of precompiled headers of faster compilation than #included traditional headers, as well as and faster processing during the linking phase.[5] This is because modules are not handled by the C preprocessor during the preprocessing step, but rather directly by the compiler during compilation. Modules also reduce boilerplate by allowing code to be implemented in a single file, rather than being separated across a header file and source implementation, although separation of "interface file" and "implementation file" is still possible with modules. Modules eliminate the necessity of #include guards or #pragma once, as modules do not directly modify the source code. Modules, unlike headers, do not have to be processed or recompiled multiple times.[5] However, similar to headers, any change in a module necessitates the recompilation of not only the module itself but also all its dependencies, and the dependencies of those dependencies, et cetera. Like headers, modules do not permit circular dependencies, and will not compile.[6]

A module is imported using the keyword import followed by a module name[a], while a module is declared with export module followed by the name. All symbols within a module meant to be exposed publicly are marked export, and importing the module exposes all exported symbols to the translation unit. If a module is never imported, it will never be linked.[7] Modules can export named symbols, but not macros which are consumed before compilation.

Unlike header inclusions, the order of import statements do not matter.[5] A module can allow for transitive imports by marking an import with export import, which re-exports the imported module to a translation unit that imports the first module.[1] Modules do not enforce any notion of namespaces, but it is not uncommon to see projects manually associate modules to namespaces (for example, a namespace like exampleproj::util::contents being tied to the module exampleproj.util.contents).[1] Because using statements will not be included into importing files (unless explicitly marked export), it is much less likely that using a using statement to bring symbols into the global namespace will cause name clashes within module translation units.

Currently, only GCC, Clang, and MSVC offer support for modules.[8]

Standard library modules

Since C++23, the C++ standard library has been exported as a module as well, though as of currently it must be imported in its entirety (using import std;).[9] The C++ standards offer two standard library modules:

Name Description
std Exports all declarations in namespace std and global storage allocation and deallocation functions that are provided by the importable C++ library headers including C library facilities (although declared in standard namespace).
std.compat Exports the same declarations as the named module std, and additionally exports functions in global namespace in C library facilities. It thus contains "compat" in the name, meaning compatibility with C.

The module names std and std.* are reserved by the C++ standard, and thus declaring a module whose name matches either pattern will issue a compiler warning.[10] However, most compilers provide a flag to bypass or suppress that warning (for example -Wno-reserved-module-identifier in Clang and GCC).[2]

Currently, only GCC, Clang, and MSVC support standard library modules.[11]

Example

A simple example of using modules is as follows:

MyClass.cppm

export module myproject.MyClass;

import std;

export namespace myproject {

class MyClass {
private:
    int x;
    std::string name;
public:
    MyClass(int x, const std::string& name):
        x{x}, name{name} {}

    [[nodiscard]]
    int getX() const noexcept {
        return x;
    }

    void setX(int newX) noexcept {
        x = newX;
    };

    [[nodiscard]]
    std::string getName() const noexcept {
        return name;
    }

    void setName(const std::string& newName) noexcept {
        name = newName;
    }
};

}

Main.cpp

import std;

import myproject.MyClass;

using myproject::MyClass;

int main(int argc, char* argv[]) {
    MyClass me(10, "MyName");
    me.setX(15);
    std::println("Hello, {0}! {0} contains value {1}.", me.getName(), me.getX());
}

Header units

Headers may also be imported using import, even if they are not declared as modules. Imported headers are called "header units", and are designed to allow existing codebases to migrate from headers to modules more gradually.[12][13] The syntax is similar to including a header, with the difference being that #include is replaced with import. As import statements are not preprocessor directives but rather full statements of the language read by the compiler, they must be terminated by a semicolon. Header units automatically export all symbols, and differ from proper modules in that they allow the emittance of macros, meaning all translation units that import the header unit will obtain its contained macros. This offers minimal breakage between migration to modules.[5] The semantics of searching for the file depending on whether quotation marks or angle brackets are used apply here as well. For instance, one may write import <string>; to import the <string> header, or import "MyHeader.h"; to import the file "MyHeader.h" as a header unit. Most build systems, such as CMake, do not support this feature yet.

Anatomy

Module partitions and hierarchy

Modules may have partitions, which separate the implementation of the module across several files. Module partitions are declared using the syntax A:B, meaning the module A has the partition B. Module partitions cannot individually be imported outside of the module that owns the partition itself, meaning that any translation unit that requires code located in a module partition must import the entire module that owns the partition.[1]

The module partition B is linked back to the owning module A with the statement import :B; in the file containing the declaration of module A or any other module partition of A (say A:C), which implicitly resolves :B to A:B, because the module is named A. These import statements may themselves be exported by the owning module, even if the partition itself cannot be imported directly, and thus importing code from a partition is done by just importing the entire module.

Other than partitions, modules do not have a hierarchical system or "submodules", but typically use a hierarchical naming convention, similar to Java's packages[b]. Only alphanumeric characters and the period and underscore may appear in the name of a module.[14] In C++, the name of a module is not tied to the name of its file or the module's location, unlike in Java[15], and the package it belongs to must match the path it is located in.[16] For example, the modules A and A.B in theory are disjoint modules and need not necessarily have any relation, however such a naming scheme is often employed to suggest that the module A.B is somehow related or otherwise associated with the module A.

The naming scheme of a C++ module is inherently hierarchical, and the C++ standard recommends re-exporting "sub-modules" belonging to the same public API (i.e. module alpha.beta.gamma should be re-exported by alpha.beta, etc.), even though dots in module names do not enforce any hierarchy. The C++ standard recommends lower-case ASCII module names (without hyphens or underscores), even though there is technically no restriction in such names.[17] Also, because modules cannot be re-aliased or renamed (short of re-exporting all symbols in another module), module names can be prefixed with organisation/project names for both clarity and to prevent naming clashes (i.e. google.abseil instead of abseil).[17] Also, unlike Java, whose packages may typically include a TLD to avoid namespace clashes, C++ modules need not have this convention.

Module purview and global module fragment

In the above example, everything above the line export module myproject.MyClass; in the file MyClass.cppm is referred to as what is "outside the module purview", meaning what is outside of the scope of the module.[1] Typically, all #includes are placed outside the module purview between the statement module; and the declaration of export module, like so:

module; // Optional; marks the beginning of the global module fragment (mandatory if an include directive is invoked above the export module declaration)

// Headers are included in outside the module purview, before the module is declared
#include <print>
#include "MyHeader.h"

export module myproject.MyModule; // Mandatory; marks the beginning of the module preamble

// Imports of named modules and header units come after the module declaration
// Import statements are placed immediately after the module declaration and do not appear after any code or symbol declarations
// In non-module translation units, #include directives precede import statements
import std;
import <string>;
import myproject.util.UtilitySymbols;
import "Foo.h";
import <thirdlib/features/Feature.h>;

// Code here...

module: private; // Optional; marks the beginning of the private module fragment

All code which does not belong to any module exists in the so-called "unnamed module" (also known as the global module fragment), and thus cannot be imported by any module.[1]

The file containing main() may declare a module, but typically it does not (as it is unusual to export main() as it is typically only used as an entry point to the program, and thus the file is usually a .cpp file and not a .cppm file). A program is ill-formed if it exports main() and doing so causes undefined behaviour[18], but will not necessarily be rejected by the compiler.

Private module fragment

A module may declare a "private module fragment" by writing module: private;, in which all declarations or definitions after the line are visible only from within the file and cannot be accessed by translation units that import that module.[1] Any module unit that contains a private module fragment must be the only module unit of its module.

See also

Notes

  1. ^ The import keyword in C++ differs in meaning than other languages. For instance, import in Java is actually analogous to using in C++ and not C++ import. In the former, an import simply aliases the type or de-qualifies a namespace, because Java loads .class files dynamically as necessary, thus making all types available simply by fully qualifying all namespaces (rather than having to explicitly declare accessible modules). However, in C++ modules are not automatically all linked, and thus they must be manually "imported" to be made accessible, as import indicates that the translation unit must access code in the imported module. Thus, it is probably more appropriate to compare import in C++ to mod in Rust, which "declares" or indicates to the compiler to find the module to link against.
  2. ^ It is more appropriate to compare packages in Java and modules in C++, rather than modules in Java and modules in C++. Modules in C++ and Java differ in meaning. In Java, a module (which is handled by the Java Platform Module System) is used to group several packages together, while in C++ a module is a translation unit, strictly speaking.

References

  1. ^ a b c d e f g h cppreference.com (2025). "Modules (since C++20)". cppreference.com. Retrieved 2025-08-06.
  2. ^ a b "Standard C++ Modules". clang.llvm.org.
  3. ^ "Overview of modules in C++". Microsoft. 24 April 2023.
  4. ^ "Modules". clang.llvm.org.
  5. ^ a b c d "Compare header units, modules, and precompiled headers". Microsoft. 12 February 2022.
  6. ^ ISO/IEC 14882:2020. Programming Languages – C++ (3rd ed.). International Organization for Standardization. §9.3, "Module interface units and import/export rules," and §16.3, "Module dependencies."
  7. ^ ISO/IEC 14882:2020. Programming Languages – C++ (3rd ed.). International Organization for Standardization. §9.3, "Module interface units and import/export rules," and §16.2, "Module import semantics."
  8. ^ "Compiler support for C++20". cppreference.com.
  9. ^ "Standard library - Importing modules". cppreference.com.
  10. ^ cppreference.com (2025). "C++ Standard Library". cppreference.com. Retrieved 2025-08-06.
  11. ^ "Compiler support for C++23". cppreference.com.
  12. ^ "Walkthrough: Build and import header units in Microsoft Visual C++". Microsoft. 12 April 2022.
  13. ^ "Standard C++ Modules - Header Units". clang.llvm.org.
  14. ^ ISO/IEC 14882:2020. Programming Languages – C++ (3rd ed.). International Organization for Standardization. §9.2, "Module interface units and import/export rules."
  15. ^ "Creating a Package". docs.oracle.com.
  16. ^ "Managing Source and Class Files". docs.oracle.com.
  17. ^ a b "Naming guidelines for modules". isocpp.org.
  18. ^ ISO/IEC 14882:2020. Programming Languages – C++ (3rd ed.). International Organization for Standardization. §3.6.1. "Program execution: the main() function."
拜金是什么意思 吃什么对心脏好改善供血不足 老人头晕是什么原因引起的 五楼五行属什么 甘肃属于什么地区
阴囊长白毛是什么原因 伊拉克是什么人种 冷的什么 痘坑用什么药膏最有效 什么是尊严
cas是什么 女生什么时候最容易怀孕 冬的部首是什么 酱油是什么时候发明的 双子男和什么星座最配
primark是什么牌子 吃饭后胃疼是什么原因 眼睛出现飞蚊症什么原因怎么办 胆汁淤积症有什么症状 焦亚硫酸钠是什么
可见一什么hcv8jop0ns9r.cn 68年猴五行属什么hcv8jop5ns2r.cn 圆寂为什么坐着就死了hcv7jop9ns4r.cn 色彩斑斓是什么意思hcv8jop0ns9r.cn 苦瓜吃多了有什么坏处hcv8jop6ns1r.cn
肉丝炒什么好吃hcv8jop1ns8r.cn 气管炎咳嗽吃什么药最有效hcv8jop2ns0r.cn 脊椎痛什么原因hcv8jop4ns9r.cn 宝宝睡觉出汗是什么原因hcv7jop9ns1r.cn 冷冻液是什么hcv8jop1ns6r.cn
iwc手表是什么牌子0735v.com 澳门车牌号是什么样子hcv9jop6ns2r.cn 许多的近义词是什么hanqikai.com 流黄鼻涕是什么原因hcv9jop7ns2r.cn 洗纹身去医院挂什么科hcv9jop7ns1r.cn
瑶五行属什么hcv7jop5ns5r.cn 蛇缠腰是什么病怎么治hcv8jop6ns5r.cn 仓鼠是什么科动物hcv9jop2ns3r.cn gr是什么单位fenrenren.com 12月20号是什么星座hcv8jop7ns8r.cn
百度