template <typename...dummy>
class wrapper;
template < typename TYPE >
class wrapper <TYPE> {};
template < template <typename...> class TYPE, typename... PARAMS >
class wrapper < TYPE <PARAMS...> > {};
template <typename>
class templated_class {};
class normal_class {};
typedef wrapper <normal_class> normal_wrapper;
typedef wrapper < templated_class, int > templated_wrapper;
'templated_class': class template (not specialized) cannot be a template argument for 'dummy', an actual type was expected
我怎样才能使它发挥作用,使wrapper
可以接受normal_class
和templated_class
作为第一个参数显然编译上述结果超载?我觉得有一个简单的方法,但我没有看到它,因为我太担心这个问题。
的原因,我不能只写
typedef wrapper < templated_class <int> > templated_wrapper;
是因为该类型定义是由可变参数宏,它创造的 - 剥离为MCVE目的 - 是这样的:
#define first_va(f,...) f
#define createwrapper(...) \
typedef wrapper <__VA_ARGS__> first_va(__VA_ARGS__)_wrapper;
createwrapper(normal_class)
createwrapper(templated_class,int)
而且我也没有想法如何执行预处理器向导,以便在<>
之后包含所有参数,如果它甚至是可能的话。
使用模板或宏的解决方案对我来说都是可以接受的,尽管我更喜欢模板解决方案。
最后的typedef需要额外的类型名称...在这一点上templated_class不是一个类型(但templated_class是) - 因此指定'包装的'允许编译器不找'templated_class'立即.....呵呵,你可能需要扩展包装 - 'template class templated_wrapper:public wrapper {};'作为另一个模板类 –
Fox
2014-10-02 15:49:51
你不能重载类模板,只专门。而当你专注,你不能改变那种温和的论点。 – 2014-10-02 15:59:11
@Fox'typedef wrapper templated_wrapper'导致相同的错误消息(visual studio 2013)。我不确定你的'templated_wrapper'在我的问题中有什么目的。 –
Slyps
2014-10-02 15:59:20