Alexander Bily
Alexander Bily

Reputation: 975

Type traits of float (int) const

When I tried my own implementation of type traits, I compared my results with std <type_traits>. I tried to check type traits of type float (int) const, which I thought should be function. I got strange results, so I tried to pass this type to std type traits. Here is my test code:

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;

Output of this test was following:

0100000001

Meaning, that this type is compound & object, but not scalar. According to http://www.cplusplus.com/reference/type_traits/, it should be class, union or array, none of which is true. What should be correct result for this type? I am using MSVC 2015.

Upvotes: 1

Views: 207

Answers (1)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385274

This is a bug in the MSVS implementation; float(int) const is both function and compound.

Raise it on Connect, if it's not already there (which it doesn't seem to be).

I suspect the trailing const (which is supposed to be ignored/stripped) is throwing things off.

Upvotes: 1

Related Questions