C++ Logo

SG7

Advanced search

Subject: Re: type_traits vs value-based reflection world
From: Peter Dimov (pdimov_at_[hidden])
Date: 2020-11-02 10:30:08


The performance problem with the type traits isn't intrinsic, by the way -
it's because they were designed against C++03. A C++11 version,

template<class T> using is_arithmetic = integral_constant<bool, ...>;

does not cause instantiations.

But that probably will never get fixed. :-)

-----Original Message-----
From: Andrew Sutton
Sent: Monday, November 02, 2020 18:11
To: sg7_at_[hidden]
Cc: Peter Dimov
Subject: Re: [SG7] type_traits vs value-based reflection world

> 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.

Isn't there a more immediate reason for this? As far as I can see, it's not
currently possible to splice in consteval functions that take meta::info,
because the argument is not a constant expression. One can however call
meta::is_arithmetic on it.

E.g. https://cppx.godbolt.org/z/EG71jY

Good point. I'm putting the cart before the horse here (I blame lack of
coffee). "Usable in more contexts" is better motivation than compiler
performance.

Andrew


SG7 list run by sg7-owner@lists.isocpp.org

Older Archives on Google Groups