[英]can template alias be used for partial specialization?
給定模板別名
template<unsigned U>
using uint_ = integral_constant<unsigned,U>;
部分專業化
template<class T,class P>
struct size{};
如
template <class T,unsigned U>
struct size<T,uint_<U>>{};
生成警告,因為template parameter can not be deduced
為clang 3.1 template parameter can not be deduced
,而gcc 4.7沒有生成警告
那么,代碼是否格式錯誤?
代碼在C ++ 11中完全沒問題。 Clang的警告可以忽略。
另一個人說這是一個Clang bug。 如果你改變這樣的使用聲明,你可以解決它
template<unsigned T, unsigned U = T>
using uint_ = integral_constant<unsigned,U>;
作為一個有根據的猜測,顯然Clang沒有正確更新type-id中出現的模板參數的身份。 所以它在你的例子中認為結果類型uint_<U>
引用了部分特化的第一個參數(因為在uint_
中是這種情況,但不在使用點)。 或者,您可以在使用地點交換訂單
template <unsigned U,class T>
struct size<T,uint_<U>>{};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.