从另一个模块导入的导出类

问题描述 投票:2回答:1

我正在尝试使用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.*,但这也不起作用。

c++ clang++ c++-modules
1个回答
0
投票

在C ++ 20中(不是Clang中的任何原型版本,您可以使用以下任何一种方法>]

export using ::hehe;
export using hehe=hehe;

为此,有两个警告:

  1. 第一种形式必须始终使用qualified名称(因为很早以前就引入了语法来复制名称between命名空间)。
  2. 您必须首先能够使用
  3. 您导入的名称,在您的示例中不是这种情况,因为root.hehe没有导出它。 (对于类型别名方法,能够通过decltype左右命名就足够了。)

    您还可以使用export import root.hehe;重新导出被导入模块导出的everything

。没有通配符导入语法:带点的模块名称具有no语义(在C ++ 20中)。
© www.soinside.com 2019 - 2024. All rights reserved.