clang++ using.cpp -std=c++17
g++ using.cpp -std=c++17
,但是using.cpp:15:49: error: declaration of ‘using statistic<T>::value_type’ changes meaning of ‘value_type’ [-Wchanges-meaning]
15 | using typename statistic<TYPE>::value_type; \
| ^~~~~~~~~~
using.cpp:26:9: note: in expansion of macro ‘STAT’
26 | STAT(mult_by_2, value_type);
| ^~~~
using.cpp:26:25: note: used here to mean ‘using vec<T>::value_type = T’
26 | STAT(mult_by_2, value_type);
| ^~~~~~~~~~
using.cpp:15:42: note: in definition of macro ‘STAT’
15 | using typename statistic<TYPE>::value_type; \
| ^~~~
using.cpp:23:15: note: declared here
23 | using value_type = T;
| ^~~~~~~~~~
抱怨:
STAT(mult_by_2, value_type)
我已经理解,using typename statistic<value_type>::value_type
扩展到class定义,其中包括value_type
。但是第一个是来自
vec
,第二个来自
value_type
。我知道这很困惑。问题是,如何在内部制作一个
statistic</*first value_type*/>
type??
我有和想法的想法不同,因此编译器不会感到困惑哪个是哪个。因此,我可以声明
statistic
as
的统计数据
vec
一个缺点是,value_type
在复杂的类层次结构中变得很长。