On Wed, 22 Nov 2023 at 14:50, Jonathan Wakely <jwak...@redhat.com> wrote: > > On Mon, 20 Nov 2023 at 02:56, Jason Merrill wrote: > > > > Tested x86_64-pc-linux-gnu. Are the library bits OK? Any comments before I > > push this? > > The library parts are OK. > > The variable template is_trivially_copyable_v just uses > __is_trivially_copyable so should be just as efficient, and the change > to <bit> is fine. > > The variable template is_trivially_destructible_v instantiates the > is_trivially_destructible type trait, which instantiates > __is_destructible_safe and __is_destructible_impl, which is probably > why we used the built-in directly in <variant>. But that's an > acceptable overhead to avoid using the built-in in a mangled context, > and it would be good to optimize the variable template anyway, as a > separate change.
For C++20 we could do: #if __cpp_concepts template <typename _Tp> inline constexpr bool is_trivially_destructible_v = false; template <typename _Tp> requires (_Tp& __t) { __t.~_Tp(); } inline constexpr bool is_trivially_destructible_v<_Tp> = __has_trivial_destructor(_Tp); #else template <typename _Tp> inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; #endif But that won't help C++17.