I am experimenting with C++ modules, using clang 5.0, and I am trying to understand how can I export from one module something that I have imported from another module. Is that even possible?
For example, I'd like to have something like this:
// root.hehe.cppm
export module root.hehe;
class hehe
{
};
and this:
// 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!
So that in the end I can do something like
import root;
// ...
hehe myhehe;
Is such a thing possible? I also tried figuring out if there could be a way to import all the submodules of root, like import root.*, but that didn't work either.
In C++20 (not whatever prototype version in Clang), you can use either of
export using ::hehe;
export using hehe=hehe;
to do this, with two caveats:
root.hehe did not export it. (For the type alias approach, it’s sufficient to be able to name it via decltype or so.)You can also use export import root.hehe; to reexport everything exported by the module being imported. There is no wildcard import syntax: module names with dots have no semantics whatsoever (in C++20).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With