* Remove redundant partial specialization in _Nth_type
@ 2023-10-28 13:14 Feng Jisen
2023-11-03 15:36 ` Patrick Palka
2023-11-04 8:45 ` Jonathan Wakely
0 siblings, 2 replies; 3+ messages in thread
From: Feng Jisen @ 2023-10-28 13:14 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1.1: Type: text/plain, Size: 1927 bytes --]
This patch remove a redundant partial specialization in class _Nth_type.
For the original metafunction _Nth_type code,
# 0
template<typename _Tp0, typename... _Rest>
struct _Nth_type<0, _Tp0, _Rest...>
{ using type = _Tp0; };
# 1
template<typename _Tp0, typename _Tp1, typename... _Rest>
struct _Nth_type<0, _Tp0, _Tp1, _Rest...>
{ using type = _Tp0; };
# 2
template<typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
{ using type = _Tp0; };
# 3
template<size_t _Np, typename _Tp0, typename _Tp1, typename _Tp2,
typename... _Rest>
#if __cpp_concepts
requires (_Np >= 3)
#endif
struct _Nth_type<_Np, _Tp0, _Tp1, _Tp2, _Rest...>
: _Nth_type<_Np - 3, _Rest...>
{ };
we need partial specialization # 2 to deal with template argument <0, Tp0, Tp1, Tp2, ...>.
Because without concepts, both # 0 and # 3 is legal and there is no partial order relationship between them.
However, # 1 is redundant. For template argument <0, Tp0, Tp1>, #0 is instantiated and that's enough.
libstdc++-v3/ChangeLog:
* include/bits/utility.h:(_Nth_type) Remove redundant partial specialization.
diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
index bed94525642..8766dfbc15f 100644
--- a/libstdc++-v3/include/bits/utility.h
+++ b/libstdc++-v3/include/bits/utility.h
@@ -258,10 +258,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ };
#if ! __cpp_concepts // Need additional specializations to avoid ambiguities.
- template<typename _Tp0, typename _Tp1, typename... _Rest>
- struct _Nth_type<0, _Tp0, _Tp1, _Rest...>
- { using type = _Tp0; };
-
template<typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
{ using type = _Tp0; };
--
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-remove-redundant-partial-template-in-_Nth_type.patch --]
[-- Type: text/x-patch; name="0001-remove-redundant-partial-template-in-_Nth_type.patch", Size: 954 bytes --]
From 6443b75b1097ed3d1a691535a4c5e9e9a96a935a Mon Sep 17 00:00:00 2001
From: J1senn <J1senn@outlook.com>
Date: Sat, 28 Oct 2023 20:49:42 +0800
Subject: [PATCH] remove redundant partial template in _Nth_type
---
libstdc++-v3/include/bits/utility.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
index bed94525642..8766dfbc15f 100644
--- a/libstdc++-v3/include/bits/utility.h
+++ b/libstdc++-v3/include/bits/utility.h
@@ -258,10 +258,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ };
#if ! __cpp_concepts // Need additional specializations to avoid ambiguities.
- template<typename _Tp0, typename _Tp1, typename... _Rest>
- struct _Nth_type<0, _Tp0, _Tp1, _Rest...>
- { using type = _Tp0; };
-
template<typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
{ using type = _Tp0; };
--
2.42.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Remove redundant partial specialization in _Nth_type
2023-10-28 13:14 Remove redundant partial specialization in _Nth_type Feng Jisen
@ 2023-11-03 15:36 ` Patrick Palka
2023-11-04 8:45 ` Jonathan Wakely
1 sibling, 0 replies; 3+ messages in thread
From: Patrick Palka @ 2023-11-03 15:36 UTC (permalink / raw)
To: Feng Jisen; +Cc: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 2103 bytes --]
yn Sat, 28 Oct 2023, Feng Jisen wrote:
> This patch remove a redundant partial specialization in class _Nth_type.
> For the original metafunction _Nth_type code,
> # 0
> template<typename _Tp0, typename... _Rest> struct _Nth_type<0, _Tp0, _Rest...>
> { using type = _Tp0; };
> # 1
> template<typename _Tp0, typename _Tp1, typename... _Rest>
> struct _Nth_type<0, _Tp0, _Tp1, _Rest...>
> { using type = _Tp0; }; # 2
> template<typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
> struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
> { using type = _Tp0; };
> # 3
> template<size_t _Np, typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
> #if __cpp_concepts
> requires (_Np >= 3)
> #endif
> struct _Nth_type<_Np, _Tp0, _Tp1, _Tp2, _Rest...>
> : _Nth_type<_Np - 3, _Rest...>
> { };
>
> we need partial specialization # 2 to deal with template argument <0, Tp0, Tp1, Tp2, ...>.
> Because without concepts, both # 0 and # 3 is legal and there is no partial order relationship between them.
> However, # 1 is redundant. For template argument <0, Tp0, Tp1>, #0 is instantiated and that's enough.
Thanks for the patch! This looks good to me.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/utility.h:(_Nth_type) Remove redundant partial specialization.
>
>
> diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.hindex bed94525642..8766dfbc15f 100644
> --- a/libstdc++-v3/include/bits/utility.h
> +++ b/libstdc++-v3/include/bits/utility.h
> @@ -258,10 +258,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> { };
>
> #if ! __cpp_concepts // Need additional specializations to avoid ambiguities.
> - template<typename _Tp0, typename _Tp1, typename... _Rest>
> - struct _Nth_type<0, _Tp0, _Tp1, _Rest...>
> - { using type = _Tp0; };
> -
> template<typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
> struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
> { using type = _Tp0; };
> --
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Remove redundant partial specialization in _Nth_type
2023-10-28 13:14 Remove redundant partial specialization in _Nth_type Feng Jisen
2023-11-03 15:36 ` Patrick Palka
@ 2023-11-04 8:45 ` Jonathan Wakely
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2023-11-04 8:45 UTC (permalink / raw)
To: Feng Jisen; +Cc: libstdc++, gcc-patches
On Sat, 28 Oct 2023 at 14:15, Feng Jisen wrote:
>
> This patch remove a redundant partial specialization in class _Nth_type.
Thanks for the patch, I've pushed it to trunk now.
>
> For the original metafunction _Nth_type code,
> # 0
> template<typename _Tp0, typename... _Rest>
> struct _Nth_type<0, _Tp0, _Rest...>
> { using type = _Tp0; };
> # 1
> template<typename _Tp0, typename _Tp1, typename... _Rest>
> struct _Nth_type<0, _Tp0, _Tp1, _Rest...>
> { using type = _Tp0; };
> # 2
> template<typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
> struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
> { using type = _Tp0; };
> # 3
> template<size_t _Np, typename _Tp0, typename _Tp1, typename _Tp2,
> typename... _Rest>
> #if __cpp_concepts
> requires (_Np >= 3)
> #endif
> struct _Nth_type<_Np, _Tp0, _Tp1, _Tp2, _Rest...>
> : _Nth_type<_Np - 3, _Rest...>
> { };
>
> we need partial specialization # 2 to deal with template argument <0, Tp0, Tp1, Tp2, ...>.
> Because without concepts, both # 0 and # 3 is legal and there is no partial order relationship between them.
> However, # 1 is redundant. For template argument <0, Tp0, Tp1>, #0 is instantiated and that's enough.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/utility.h:(_Nth_type) Remove redundant partial specialization.
>
>
> diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h
> index bed94525642..8766dfbc15f 100644
> --- a/libstdc++-v3/include/bits/utility.h
> +++ b/libstdc++-v3/include/bits/utility.h
> @@ -258,10 +258,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> { };
>
> #if ! __cpp_concepts // Need additional specializations to avoid ambiguities.
> - template<typename _Tp0, typename _Tp1, typename... _Rest>
> - struct _Nth_type<0, _Tp0, _Tp1, _Rest...>
> - { using type = _Tp0; };
> -
> template<typename _Tp0, typename _Tp1, typename _Tp2, typename... _Rest>
> struct _Nth_type<0, _Tp0, _Tp1, _Tp2, _Rest...>
> { using type = _Tp0; };
> --
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-04 8:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-28 13:14 Remove redundant partial specialization in _Nth_type Feng Jisen
2023-11-03 15:36 ` Patrick Palka
2023-11-04 8:45 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).