I have been experimenting with C++20 modules, and there seems to be something different with the usual hpp/cpp approach. The following doesn't compile (I'm using the latest preview of MSVC).
foo.ixx
export module foo;
import std.memory;
export
struct Bar;
export
struct Foo {
std::unique_ptr<Bar> ptr;
};
bar.ixx
export module bar;
import std.core;
import foo;
struct Bar {
void func(Foo& f) {}
};
main.cpp
import foo;
import bar;
int main() {
Foo f;
}
My questions:
- Is there a better way to resolve this other than putting
FooandBarinto one file? - Does this imply that template instantiation is done before module "linking"?