I'd like to export
(C++20) an alias template. VC++ 2019 compiles the code. Clang reports an error. Which one is correct and why?
// file: m.cppm
export module m;
template<typename T> struct my_template {};
export template<typename T> using my_alias = my_template<T>;
// file: main.cpp
import m;
int main() { my_alias<int> v; }
main.cpp:2:28: error: definition of 'my_template' must be imported from module 'm' before it is required
int main() { my_alias<int> v; }
^
m.cppm:3:29: note: previous definition is here
template<typename T> struct my_template {};
This program is valid according to the current C++20 draft (which differs significantly from the Modules TS): export
influences name lookup, not any more abstract notion of “usability”. One could obtain access to the non-exported my_template
by any of a variety of means, including template argument deduction from an object whose type is one of its specializations.
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