3
如果我想要一些類型是專用於它的模板參數我一般使用結構:你可以專門使用語句嗎?
template <bool value>
struct IsTrue;
template <>
struct IsTrue<true> : std::true_type {};
template <>
struct IsTrue<false> : std::false_type {};
一個空的結構是獲得其從繼承唯一的功能是不是真的那麼從using
聲明不同,所以我想知道,using
陳述中是否存在類似於模板專門化的內容?下面我想要的僞代碼:
template <bool value>
using IsTrue;
template <>
using IsTrue<true> = std::true_type;
template <>
using IsTrue<false> = std::false_type;
是這樣的可能嗎?它會被稱爲什麼?
我不知道它是否可能,但是如果它使用'using'語句就像'typedef'那樣創建* type別名*。 –
查看類型別名http://en.cppreference.com/w/cpp/language/type_alias –
不,別名模板不能部分或明確專用。這是一件好事,因爲否則模板參數推導不能查看它。 –