我無法得到這個工作。我想它來檢查基本類型也爲基本類型的指針:Boost :: type_traits基本類型和指針
template<typename T> struct non_void_fundamental :
boost::integral_constant<bool,
(boost::is_fundamental<T>::value && !boost::is_same<T, void>::value)
|| (boost::is_fundamental<*T>::value && !boost::is_same<*T, void>::value)
>
{ };
也許有人可以幫我點我在正確的方向。
編輯:這是特別是第四行不做我想要的,其餘的正常工作。
編輯2:點是,這產生在下面的例子中下面的輸出:
int* p = new int(23);
cout << non_void_fundamental<double>::value << endl // true
cout << non_void_fundamental<some_class>::value << endl // false
cout << non_void_fundamental<p>::value << endl // true
編輯3:由於Kerrek SB,我有此知道,但它是生產一些錯誤。
template<typename T> struct non_void_fundamental :
boost::integral_constant<bool,
(boost::is_fundamental<T>::value && !boost::is_same<T, void>::value)
|| (boost::is_pointer<T>::value && boost::is_fundamental<boost::remove_pointer<T>::type>::value && !boost::is_same<boost::remove_pointer<T>::type, void>::value)
>
{ };
誤差修改:
FILE:99:61: error: type/value mismatch at argument 1 in temp
late parameter list for 'template<class T> struct boost::is_fundamental'
FILE:99:61: error: expected a type, got 'boost::remove_poi
nter<T>::type'
FILE:99:125: error: type/value mismatch at argument 1 in tem
plate parameter list for 'template<class T, class U> struct boost::is_same'
FILE:99:125: error: expected a type, got 'boost::remove_po
inter<T>::type'
你有什麼錯誤? – 0x499602D2
這不是關於它產生的錯誤。但更多關於正確的方法,這絕對不行。看我的編輯。 – Tim
你確定'boost :: is_fundamental <*T>'*不是*應該是'boost :: is_fundamental''? 'is_same <*T>' –
0x499602D2