有特殊含义的 C++ 标识符: module (C++20 起) - cppreference.com

有特殊含义的 C++ 标识符: module (C++20 起)

来自cppreference.com
< cpp


 
 
C++ 语言
 
 

用法

注解

示例

module;            // 开始全局模块片段

#include <string>

export module foo; // 结束全局模块片段
                   // 为具名模块 foo 声明主模块接口单元
                   // 开始模块单元范围

export std::string f();

module : private;  // 结束模块接口单元中可以影响其他翻译单元行为的部分
                   // 开始私有模块片段

std::string f()
{
    return "foo";
}

参阅