On Thu, Nov 12, 2026 at 11:39 AM Jonathan Wakely <[email protected]> wrote:

> This helper macro is defined in <type_traits> but only used in a test.
>
> The uses of it in our headers were removed in these commits:
> r5-4826-g847e9cf81e5101 Define __void_t and SFINAE-friendly
> iterator_traits.
> r6-1925-g4f44c5556fc384 ptr_traits.h (__ptrtr_elt_type, [...]): Remove
> r7-3818-g57c4fbc64b6c15 Simplify reference_wrapper nested typedefs
>
> So we've kept it around unnecessarily for a decade.  Remove it from the
> public header and update the test to not require it.
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/type_traits (_GLIBCXX_HAS_NESTED_TYPE): Remove
>         macro.
>         * testsuite/20_util/reference_wrapper/typedefs-3.cc: Define
>         test traits without using _GLIBCXX_HAS_NESTED_TYPE.
> ---
>
> Tested 20_util/* and running the other tests now on x86_64-linux.
>
LGTM

>
>  libstdc++-v3/include/std/type_traits          | 14 ---------
>  .../20_util/reference_wrapper/typedefs-3.cc   | 29 ++++++++++++-------
>  2 files changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/type_traits
> b/libstdc++-v3/include/std/type_traits
> index 83dbad17ade9..d4199dd5a33b 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -3045,20 +3045,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      using __detected_or_t
>        = typename __detected_or<_Default, _Op, _Args...>::type;
>
> -  /**
> -   *  Use SFINAE to determine if the type _Tp has a publicly-accessible
> -   *  member type _NTYPE.
> -   */
> -#define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE)                               \
> -  template<typename _Tp, typename = __void_t<>>
>       \
> -    struct __has_##_NTYPE                                              \
> -    : false_type                                                       \
> -    { };                                                               \
> -  template<typename _Tp>                                               \
> -    struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>>         \
> -    : true_type
>       \
> -    { };
> -
>    template <typename _Tp>
>      struct __is_swappable;
>
> diff --git
> a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
> b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
> index 2b2b36108c6d..9c7899e32085 100644
> --- a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
> +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc
> @@ -44,24 +44,33 @@ struct S12 : S1, S2 { };
>
>  struct S012 : S0, S1, S2 { };
>
> -using std::true_type;
> -using std::false_type;
> -using std::__void_t;
> -
> -_GLIBCXX_HAS_NESTED_TYPE(argument_type)
> -_GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
> -_GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
> +template<typename> using void_t = void;
>
> +template<typename T, typename = void>
> +  struct has_arg_type
> +  : std::false_type
> +  { };
>  template<typename T>
> -  struct has_arg_type : __has_argument_type<T>
> +  struct has_arg_type<T, void_t<typename T::argument_type>>
> +  : std::true_type
>    { };
>
> +template<typename T, typename = void>
> +  struct has_1st_arg_type
> +  : std::false_type
> +  { };
>  template<typename T>
> -  struct has_1st_arg_type : __has_first_argument_type<T>
> +  struct has_1st_arg_type<T, void_t<typename T::first_argument_type>>
> +  : std::true_type
>    { };
>
> +template<typename T, typename = void>
> +  struct has_2nd_arg_type
> +  : std::false_type
> +  { };
>  template<typename T>
> -  struct has_2nd_arg_type : __has_second_argument_type<T>
> +  struct has_2nd_arg_type<T, void_t<typename T::second_argument_type>>
> +  : std::true_type
>    { };
>
>  template<typename T, bool = has_arg_type<T>::value>
> --
> 2.56.0
>
>

Reply via email to