作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我阅读了有关 C++ 中的模块的内容,但有些事情我真的无法理解该怎么做。我想知道如何使用当前的合并模块提案有效地将一个 c++ 模块拆分为多个文件。
假设我有两个要导出的类。我想拆分我的 ixx 文件,以便这些类中的每一个的实现都保留在单独的文件中。
我想象的是这样的:
接口(interface).ixx:
export module MyModule;
export namespace MyLib {
struct A {
void doStuff();
};
struct B {
A myA;
void otherStuff();
};
}
然后,我想像这样实现我的类,
A.ixx:
module MyModule;
// import self??
MyLib::A::doStuff() {
// stuff...
}
B.ixx
module MyModule;
// import self again??
MyLib::B::otherStuff() {
myA.doStuff();
}
我想知道的是:无论文件如何,模块是否知道它的接口(interface)?如果没有,是否有另一种方法可以将模块拆分为多个文件?我知道在那种情况下这可能看起来很愚蠢,但是对于大模块中的大类,将事物分开是很诱人的。
最佳答案
在merged module proposal , [模块.单元]/8:
A module-declaration that contains neither
export
nor a module-partition implicitly imports the primary module interface unit of the module as if by a module-import-declaration.
这意味着模块实现单元隐式导入模块的主要模块接口(interface)。
关于c++ - 如何将一个模块拆分成多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39161627/
我是一名优秀的程序员,十分优秀!