From 6b7e6d3e11a90c3ebd9899c5a489fe30345df7b4 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Tue, 12 Aug 2025 11:53:11 -0600 Subject: [PATCH] :bug: Fix ICE with use of `__typeof__` Problem: - Compilers are finicky with use of `__typeof__` and may ICE. Solution: - Minimize use of `__typeof__` to where we know the argument is a type. --- include/stdx/utility.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/stdx/utility.hpp b/include/stdx/utility.hpp index d040bf7..910622e 100644 --- a/include/stdx/utility.hpp +++ b/include/stdx/utility.hpp @@ -145,6 +145,8 @@ struct from_any { constexpr operator int() const { return 0; } }; +struct value_marker {}; + struct type_val { template >> @@ -152,6 +154,14 @@ struct type_val { return t; } friend constexpr auto operator+(type_val const &f) -> type_val { return f; } + + template >> + friend constexpr auto operator*(T, U const &) -> value_marker { + return {}; + } + friend constexpr auto operator*(type_val const &f) -> type_val { return f; } + // NOLINTNEXTLINE(google-explicit-constructor) template constexpr operator T() const { if constexpr (std::is_default_constructible_v) { @@ -164,7 +174,7 @@ struct type_val { }; template constexpr inline auto is_type = true; -template <> constexpr inline auto is_type = false; +template <> constexpr inline auto is_type = false; class cx_base { struct unusable {}; @@ -226,8 +236,8 @@ template constexpr auto is_ct_v = is_ct_v; #ifndef STDX_IS_TYPE #define STDX_IS_TYPE(...) \ - ::stdx::cxv_detail::is_type<__typeof__(::stdx::cxv_detail::from_any( \ - __VA_ARGS__))> + ::stdx::cxv_detail::is_type #endif #ifndef CX_VALUE