sms*_*sms 5 c++ clang clang++ c++20
我想export(C ++ 20)别名模板。VC ++ 2019编译代码。Clang报告错误。哪一个是正确的,为什么?
// file: m.cppm
export module m;
template<typename T> struct my_template {};
export template<typename T> using my_alias = my_template<T>;
Run Code Online (Sandbox Code Playgroud)
// file: main.cpp
import m;
int main() { my_alias<int> v; }
Run Code Online (Sandbox Code Playgroud)
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 {};
Run Code Online (Sandbox Code Playgroud)
根据当前的 C++20 草案(与模块 TS 显着不同),该程序是有效的:export影响名称查找,而不是 \xe2\x80\x9cusability\xe2\x80\x9d 的任何更抽象的概念。my_template人们可以通过多种方式中的任何一种来访问非导出内容,包括从类型为其专业化之一的对象进行模板参数推导。
| 归档时间: |
|
| 查看次数: |
204 次 |
| 最近记录: |