On Wed, 7 Sept 2022 at 01:46, Patrick Palka via Libstdc++
<libstd...@gcc.gnu.org> wrote:
>
> Instead of defining these in terms of a helper class template
> and the relatively expensive __remove_cv_t, just declare four
> explicit specializations of the main template, one for each choice
> of cv-quals.
>
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?

Yes, and we should do the same for is_void_v and  is_null_pointer_v.
Even though the class templates they instantiate will be cheaper now,
they can still avoid any class template instantiation.

> The is_void change alone reduces memory usage for join.cc by
> almost 1%.

Also in my queue of trait refactoring, but I haven't tested if these
are worth doing yet:

template<typename T>
  struct is_object : is_const<const T>::type { };
template<>
  struct is_object<void> : false_type { };
template<>
  struct is_object<const void> : false_type { };
// and so on for volatile and const volatile

And we could define is_object_v as simply is_const_v<const T> && is_void_v<T>.

Improving is_object should benefit <ranges> and also the is_scalar
change proposed at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96710#c2

Reply via email to