2016-03-29 53 views
1

当我尝试自己实现的类型特征时,我将结果与std <type_traits>进行了比较。我试图检查类型float (int) const,我认为应该是功能的特征。我得到了奇怪的结果,所以我试图将这种类型传递给std类型特征。这是我的测试代码:float(int)的类型特征const

该测试的
std::cout << std::is_function<float (int) const>::value; 
std::cout << std::is_compound<float(int) const>::value; 
std::cout << std::is_pointer<float(int)const>::value; 
std::cout << std::is_class<float(int)const>::value; 
std::cout << std::is_union<float(int)const>::value; 
std::cout << std::is_member_pointer<float(int)const>::value; 
std::cout << std::is_array<float(int)const>::value; 
std::cout << std::is_scalar<float(int)const>::value; 
std::cout << std::is_enum<float(int)const>::value; 
std::cout << std::is_object<float(int)const>::value; 

产量为以下:

0100000001 

含义,这种类型的化合物是对象&,但不是标量。根据http://www.cplusplus.com/reference/type_traits/,它应该是类,联合或数组,其中没有一个是真的。这种类型应该是正确的结果?我正在使用MSVC 2015.

+1

你链接页面的哪一部分让你认为'float(int)const'应该是一个类,联合体或数组类型? – user2357112

+0

事实上,它是复合的,但不是标量的对象只留下这3种可能性。 –

+0

此外,你已经发布了10行,每行应输出一位输出,但只输出8位输出。您的代码和输出不匹配。 – user2357112

回答

1

这是MSVS实现中的一个错误; float(int) const is both function and compound

在Connect上提高它,如果它不在那里(它似乎不是)。

我怀疑尾随const(这应该被忽略/剥离)正在抛弃东西。

+0

似乎在模板部分专用于函数的情况下,remove_cv不起作用。 GCC实施专门针对每种可能的CV组合。 –