[英]partial template specialization error
我正在編寫一個容器類,該容器類的大小小於閾值,將std :: array作為內核,較大的大小使用std :: vector。
這是我的工具。
template<typename, size_t, bool>
class VectorStorage {
};
template<typename T, size_t DIM>
class VectorStorage<T, DIM, bool_const_v<(DIM < threshold)> > : public kernel_t<T,
DIM, 1> { // impelementaion}
template<typename T, size_t DIM>
class VectorStorage<T, DIM, bool_const_v<(DIM >= threshold)> > : public kernel_t<T,
DIM, 1> { // impelementaion}
我收到以下錯誤? 鑒於SFINAE不適用於clas specialiaziton,甚至有可能這樣做嗎? 我正在使用-std = c ++ 1y的clang
非類型模板參數取決於部分專業化的模板參數
將計算結果放入默認模板參數中。
template<typename T, size_t DIM, bool ISSMALL = (DIM < threshold)>
class VectorStorage {
/* default implementation for small case */
};
template<typename T, size_t DIM>
class VectorStorage<T, DIM, false> {
/* implementation for big case */
};
您也可以切換它們,或使用兩個部分的專業化。 如果您偏執狂並想隱藏ISSMALL
請添加一個包裝器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.