Why is type trait is_bool absent in the Standard? Though the bool is an integral type it is a special type that differs from any other integral type. It is more convinient to use is_bool instead of std::is_same and the name is_bool is well known in some other languages.
2012/8/26 Vlad from Moscow <vlad....@mail.ru>:
> Why is type trait is_bool absent in the Standard? Though the bool is an
> integral type it is a special type that differs from any other integral
> type. It is more convinient to use is_bool instead of std::is_same and the
> name is_bool is well known in some other languages.
I tend to agree, and a very similar case would be is_nullptr_t.
Am 26.08.2012 22:30 schrieb "Vlad from Moscow" <vlad....@mail.ru>:
>
>
> понедельник, 27 августа 2012 г., 0:10:56 UTC+4 пользователь Nikolay Ivchenkov написал:
>>
>> On Sunday, August 26, 2012 6:18:32 PM UTC+4, Daniel Krügler wrote:
>>>
>>> 2012/8/26 Vlad from Moscow <vlad....@mail.ru>:
>>> > Why is type trait is_bool absent in the Standard?
>> I can enumerate dozens of "special" types. What is the point in having such templates? We might have
>>
>> template <class T1, class T2>
>> struct is_affined :
>> is_same<T1 const volatile, T2 const volatile> {};
>>
>> and use is_affined<T, void> instead of is_void<T>, is_affined<T, nullptr_t> instead of is_nullptr_t<T>, and so on.
>>
>
> First of all bool is indeed a special type compared to all other types including integral types.
I would agree with this. Bool is the only integral type that cannot represent any number (not even zero and one; despite most current implementations treating it as such).
--