我正在使用clang 5.0
试验C ++模块,我试图了解如何从一个模块导出我从另一个模块导入的内容。这甚至可能吗?
例如,我想要这样的东西:
// root.hehe.cppm
export module root.hehe;
class hehe
{
};
和此:
// root.cppm
export module root;
import root.hehe;
export class hehe; // ... doesn't work!
export hehe; // Also doesn't work!
export import root.hehe; // No dice!
所以最后我可以做一些像
这样的事情import root;
// ...
hehe myhehe;
这样的事情可能吗?我还试图弄清楚是否可以导入root
的所有子模块,如import root.*
,但这也不起作用。
答案 0 :(得分:0)
在C ++ 20(不是Clang中的任何原型版本)中,您可以使用
export using ::hehe;
export using hehe=hehe;
为此,有两个警告:
root.hehe
没有导出它。 (对于类型别名方法,只需通过decltype
命名即可。)您还可以使用export import root.hehe;
重新导出要导入的模块导出的所有内容。没有通配符导入语法:带点的模块名称不具有没有语义(在C ++ 20中)。