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