From 2652c043da2ac707d858aeb2684846f164bea32e Mon Sep 17 00:00:00 2001 From: Benedek Kupper Date: Thu, 2 Jul 2026 14:10:02 +0200 Subject: [PATCH] type_traits: fix empty pack indexing Compiling with C++26 fails on empty packs with this message: include/stdx/type_traits.hpp:302:7: error: cannot index an empty pack 302 | using nth_t = | ^~~~~ The fix is to prioritize __type_pack_element over C++26 pack indexing in type_traits.hpp, since the builtin evaluates lazily (only when a member is accessed) while pack indexing is checked eagerly when the class is instantiated with an empty pack. Signed-off-by: Benedek Kupper --- include/stdx/type_traits.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/stdx/type_traits.hpp b/include/stdx/type_traits.hpp index 34c3602..7e125bb 100644 --- a/include/stdx/type_traits.hpp +++ b/include/stdx/type_traits.hpp @@ -300,10 +300,10 @@ STDX_PRAGMA(diagnostic ignored "-Wc++26-extensions") #endif template using nth_t = -#if __cpp_pack_indexing >= 202311L - Ts...[N]; -#elif __has_builtin(__type_pack_element) +#if __has_builtin(__type_pack_element) __type_pack_element; +#elif __cpp_pack_indexing >= 202311L + Ts...[N]; #else boost::mp11::mp_at_c, N>; #endif