I was reading about modules, and I wished to do something like this:
a.cpp
module foo.a;
export namespace foo {
struct A {
void doA();
};
}
import foo.b;
void foo::A::doA() {
B{}.doB();
}
b.cpp
module foo.b;
export namespace foo {
struct B {
void doB();
void start();
};
}
import foo.a;
import std.io;
void foo::B::doB() {
std::cout << "Stuff done!" << std::endl;
}
void foo::B::start() {
A{}.doA();
}
main.cpp
import foo.b;
int main() {
foo::B{}.start();
}
Since module interfaces cannot use each other, for that to work, everything after the exported namespace must not be part of the interface. Is the above correct according to the current TS? For circular dependency in the implementation, is it required to split it into another file?