我目前正在使用 Visual Studio 2022 Update 17.1.6,我发现导出类型别名有一些有趣的东西。由于我不明白的原因,当我导出某些数据类型的类型别名(例如std::vector<std::string>在模块接口文件中)时,我可以在导入它的文件中使用std::vector<>和。std::string例如:
modInterface.ixx
export module words;
import <iostream>
import <vector>;
import <string>;
...
export using Words = std::vector<std::string>;
...
Run Code Online (Sandbox Code Playgroud)
在内部分区中:
modInternalPartition.cpp
module words:wordsIP;
import words;
//This compiles as expected
Words wordStorage;
//Why does my compiler sees below as correct, and compiles it without error?
std::vector<int> numStorage = { 1, 2, 3, 4 };
//Why does my compiler also sees below as correct, and compiles it without error?
std::string text = …Run Code Online (Sandbox Code Playgroud)