noj*_*han 5 c++ templates typedef typename
我不确定为什么不使用g ++编译以下代码:
t.cpp: In instantiation of ‘Distrib<double>’:
t.cpp:28:56: instantiated from ‘Sampler<Distrib<Solution<double> > >’
t.cpp:35:48: instantiated from here
t.cpp:16:45: erreur: ‘double’ is not a class, struct, or union type
t.cpp:18:43: erreur: ‘double’ is not a class, struct, or union type
Run Code Online (Sandbox Code Playgroud)
我期望能够AtomType在嵌套模板之间传播类型……
t.cpp: In instantiation of ‘Distrib<double>’:
t.cpp:28:56: instantiated from ‘Sampler<Distrib<Solution<double> > >’
t.cpp:35:48: instantiated from here
t.cpp:16:45: erreur: ‘double’ is not a class, struct, or union type
t.cpp:18:43: erreur: ‘double’ is not a class, struct, or union type
Run Code Online (Sandbox Code Playgroud)
在你的Sampler班级里,你有:
typedef typename Distrib<AtomType>::Matrix Matrix;
Run Code Online (Sandbox Code Playgroud)
这里,AtomType是double,所以这是
typedef typename Distrib<double>::Matrix Matrix;
Run Code Online (Sandbox Code Playgroud)
然后在你的Distrib课堂上,这条线
typedef typename SOLT::AtomType AtomType;
Run Code Online (Sandbox Code Playgroud)
扩展到
typedef typename double::AtomType AtomType;
Run Code Online (Sandbox Code Playgroud)
因此出现错误消息。我想你希望课堂上的线路Sampler是:
typedef typename DT::Matrix Matrix;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2179 次 |
| 最近记录: |