Closed Little-Flower-171 closed 5 years ago
Per [meta.unary]/2:
Each of these templates shall be a
Cpp17UnaryTypeTrait
([meta.rqmts]) with a base characteristic oftrue_type
if the corresponding condition istrue
, otherwisefalse_type
.
true_type
and false_type
are specializations of integral_constant
. Per the class synopsis in [meta.help], specializations of integral_constant
have both a member value
, with the same value as the non-type template parameter, and a member type
that is an alias for the same specialization of integral_constant
.
So yes, is_void
is a trait.
Hi @CaseyCarter,
Thank you for your quick reply and thank you for your patience!
I just realized what a severe mistake I just made in that I forgot the ::type
member of std::integral_constant
, in turn std::is_void
. This shows that I did not think of it thoroughly before I judge it as a "mistake." I apologize for that.
On the other hand, I still suggest that std::decay
(or std::add_*
, std::remove_*
, std::make_[un]signed
, std::aligned_storage
, std::aligned_union
, std::common_type
, std::[basic_]common_reference
, std::underlying_type
, std::invoke_result
(or previously std::result_of
,) std::void_t
, std::type_identity
, std::enable_if
, std::conditional
, etc.; I chose std::decay
simply because it first bumped up in my mind) makes a better example, cuz:
std::is_void
is ::value
instead of ::type
, which is merely for convenience, whereas most traits use ::type
as the primary "return value," with or without a (secondary) ::value
. Opting for std::decay
(or ...) may better demonstrate this idea. std::is_void
is a (type) trait is that it has ::type
rather than that ::value
also fulfills the condition of a trait, cuz most people (like stupid and despicable me!) may be more alert to the ::value
of it. This is purely a suggestion. If it seems too silly for you, just discard it! :smile: Have a nice day and keep on good working!
Currently
std::is_void
is used as an example of type trait. Butstd::is_void
contains::value
instead of::type
, thus not fitting with the definition of "trait."