On 06/08/2021 1:55, Gavin Lambert via Boost wrote:
On 5/08/2021 8:09 pm, Andrey Semashev wrote:
On 8/5/21 4:18 AM, Gavin Lambert wrote:
No, not really. Not only because needing is_constant_evaluated does not equate to needing type traits or metaprogramming, but because if the macro check says "no" then you've included
for nothing. Yes, really. That's the header in which std::is_constant_evaluated is defined (as well as the feature macro you're wanting to check), so if you're wanting to use it then you have to include the header anyway.
There's not really any point in making the include itself conditional (even if you could), except perhaps on something more generic (such as "is C++11 or later", to detect cases when the header wouldn't exist).
The point is reducing compile times. When all you need from
is is_constant_evaluated, it is wasteful to include the header, especially if that component doesn't exist. The probability that any real-world translation unit does not already include
is approximately zero. More than half the other STL headers implicitly include it anyway. (Or at least some internal equivalent.)
Except for those object files not using the STL, which are a lot if you want a decent compilation speed. Ion