C++ Logo

sg7

Advanced search

Re: [SG7] type_traits vs value-based reflection world

From: Andrew Sutton <asutton.list_at_[hidden]>
Date: Mon, 2 Nov 2020 09:02:02 -0500
>
> Why is needed is_arithmetic in the "reflection world" ?
>
> Does std::is_arithmetic< typename(reflexpr(int)) >::value is the same as
> reflexpr(int)::is_arithmetic() ?
>

A constexpr-based model for type traits should reduce the number of class
template instantiations needed during compilation. Instantiating classes
can be costly (in terms of analyses performed and memory required for
specializations). Calling a non-template constexpr function is relatively
cheap by comparison.

Also, reflexpr doesn't return classes, so it would be
is_arithmetic(reflexpr(int));

Andrew

Received on 2020-11-02 08:02:15