p1.cpp
export module m:p1;
template<typename>
class Incognita;
export template<typename T>
class Variable
{
public:
Incognita<T> foo() const { return {*this}; }
};
p2.cpp
export module m:p2;
import :p1;
template<typename T>
class Incognita
{
public:
Incognita(const Variable<T> &) {}
};
m.cpp
export module m;
export import :p1;
export import :p2;
example.cpp
import m;
int main()
{
Variable<double> x;
auto bar = x.foo();
}
example.cpp:7:14: error: implicit instantiation of undefined template 'Incognita<double>'
7 | auto bar = x.foo();
| ^
p1.cpp:4:7: note: template is declared here
4 | class Incognita;
| ^
p1.cpp:11:16: error: implicit instantiation of undefined template 'Incognita<double>'
11 | Incognita<T> foo() const { return {*this}; }
| ^
example.cpp:7:14: note: in instantiation of member function 'Variable<double>::foo' requested here
7 | auto bar = x.foo();
| ^
p1.cpp:4:7: note: template is declared here
4 | class Incognita;
| ^
p1.cpp:11:37: error: implicit instantiation of undefined template 'Incognita<double>'
11 | Incognita<T> foo() const { return {*this}; }
| ^
p1.cpp:4:7: note: template is declared here
4 | class Incognita;
| ^
https://godbolt.org/z/naq543aqW