我无法得到这个工作。我想它来检查基本类型也为基本类型的指针: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