* [PATCH] libstdc++/ranges: Define _S_has_simple_call_op on newer adaptors
@ 2024-01-17 2:36 Patrick Palka
2024-01-17 7:22 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2024-01-17 2:36 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Patrick Palka
Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
-- >8 --
This compile-time and diagnostic improvement[1] is less important in
C++23 mode where deducing this is available and used in _Pipe, but for
benefit of C++20 mode and for consistency let's set the flag on the most
recently added range adaptors which lack it.
[1]: Defining _S_has_simple_call_op=true for a range adaptor closure
object signals that the adaptor has an operator() that's not overloaded
according to the constness/value category of the object, which in turn
allows us to implement the operator() of the composition of such adaptors
in a simpler way.
libstdc++-v3/ChangeLog:
* include/std/ranges (views::_Adjacent::_S_has_simple_call_op):
Define to true.
(views::_AsRvalue::_S_has_simple_call_op): Likewise.
(views::_Enumerate::_S_has_simple_call_op): Likewise.
(views::_AsConst::_S_has_simple_call_op): Likewise.
---
libstdc++-v3/include/std/ranges | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 7ef835f486a..66502cc1da4 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -5669,6 +5669,8 @@ namespace views::__adaptor
else
return adjacent_view<all_t<_Range>, _Nm>(std::forward<_Range>(__r));
}
+
+ static constexpr bool _S_has_simple_call_op = true;
};
template<size_t _Nm>
@@ -8844,6 +8846,8 @@ namespace views::__adaptor
else
return as_rvalue_view(std::forward<_Range>(__r));
}
+
+ static constexpr bool _S_has_simple_call_op = true;
};
inline constexpr _AsRvalue as_rvalue;
@@ -9147,6 +9151,8 @@ namespace views::__adaptor
constexpr auto
operator() [[nodiscard]] (_Range&& __r) const
{ return enumerate_view<all_t<_Range>>(std::forward<_Range>(__r)); }
+
+ static constexpr bool _S_has_simple_call_op = true;
};
inline constexpr _Enumerate enumerate;
@@ -9253,6 +9259,8 @@ namespace views::__adaptor
else
return as_const_view(std::forward<_Range>(__r));
}
+
+ static constexpr bool _S_has_simple_call_op = true;
};
inline constexpr _AsConst as_const;
--
2.43.0.367.g186b115d30
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libstdc++/ranges: Define _S_has_simple_call_op on newer adaptors
2024-01-17 2:36 [PATCH] libstdc++/ranges: Define _S_has_simple_call_op on newer adaptors Patrick Palka
@ 2024-01-17 7:22 ` Jonathan Wakely
2024-03-27 12:46 ` Patrick Palka
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2024-01-17 7:22 UTC (permalink / raw)
To: Patrick Palka; +Cc: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 2522 bytes --]
On Wed, 17 Jan 2024, 02:37 Patrick Palka, <ppalka@redhat.com> wrote:
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
>
OK
> -- >8 --
>
> This compile-time and diagnostic improvement[1] is less important in
> C++23 mode where deducing this is available and used in _Pipe, but for
> benefit of C++20 mode and for consistency let's set the flag on the most
> recently added range adaptors which lack it.
>
> [1]: Defining _S_has_simple_call_op=true for a range adaptor closure
> object signals that the adaptor has an operator() that's not overloaded
> according to the constness/value category of the object, which in turn
> allows us to implement the operator() of the composition of such adaptors
> in a simpler way.
>
> libstdc++-v3/ChangeLog:
>
> * include/std/ranges (views::_Adjacent::_S_has_simple_call_op):
> Define to true.
> (views::_AsRvalue::_S_has_simple_call_op): Likewise.
> (views::_Enumerate::_S_has_simple_call_op): Likewise.
> (views::_AsConst::_S_has_simple_call_op): Likewise.
> ---
> libstdc++-v3/include/std/ranges | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/ranges
> b/libstdc++-v3/include/std/ranges
> index 7ef835f486a..66502cc1da4 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -5669,6 +5669,8 @@ namespace views::__adaptor
> else
> return adjacent_view<all_t<_Range>,
> _Nm>(std::forward<_Range>(__r));
> }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> template<size_t _Nm>
> @@ -8844,6 +8846,8 @@ namespace views::__adaptor
> else
> return as_rvalue_view(std::forward<_Range>(__r));
> }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> inline constexpr _AsRvalue as_rvalue;
> @@ -9147,6 +9151,8 @@ namespace views::__adaptor
> constexpr auto
> operator() [[nodiscard]] (_Range&& __r) const
> { return enumerate_view<all_t<_Range>>(std::forward<_Range>(__r));
> }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> inline constexpr _Enumerate enumerate;
> @@ -9253,6 +9259,8 @@ namespace views::__adaptor
> else
> return as_const_view(std::forward<_Range>(__r));
> }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> inline constexpr _AsConst as_const;
> --
> 2.43.0.367.g186b115d30
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libstdc++/ranges: Define _S_has_simple_call_op on newer adaptors
2024-01-17 7:22 ` Jonathan Wakely
@ 2024-03-27 12:46 ` Patrick Palka
0 siblings, 0 replies; 3+ messages in thread
From: Patrick Palka @ 2024-03-27 12:46 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Patrick Palka, gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 3413 bytes --]
On Wed, 17 Jan 2024, Jonathan Wakely wrote:
>
>
> On Wed, 17 Jan 2024, 02:37 Patrick Palka, <ppalka@redhat.com> wrote:
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
>
>
> OK
Thanks a lot. For the record I ended up not pushing this patch because
all the range adaptors it touches are C++23 ones and so ...
>
>
>
> -- >8 --
>
> This compile-time and diagnostic improvement[1] is less important in
> C++23 mode where deducing this is available and used in _Pipe, but for
> benefit of C++20 mode
... this isn't true. There's no real benefit in setting this flag for
standard C++23 range adaptors (besides consistency I guess, but OTOH not
setting it means more testing coverage for the deducing this code path).
> and for consistency let's set the flag on the most
> recently added range adaptors which lack it.
>
> [1]: Defining _S_has_simple_call_op=true for a range adaptor closure
> object signals that the adaptor has an operator() that's not overloaded
> according to the constness/value category of the object, which in turn
> allows us to implement the operator() of the composition of such adaptors
> in a simpler way.
>
> libstdc++-v3/ChangeLog:
>
> * include/std/ranges (views::_Adjacent::_S_has_simple_call_op):
> Define to true.
> (views::_AsRvalue::_S_has_simple_call_op): Likewise.
> (views::_Enumerate::_S_has_simple_call_op): Likewise.
> (views::_AsConst::_S_has_simple_call_op): Likewise.
> ---
> libstdc++-v3/include/std/ranges | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
> index 7ef835f486a..66502cc1da4 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -5669,6 +5669,8 @@ namespace views::__adaptor
> else
> return adjacent_view<all_t<_Range>, _Nm>(std::forward<_Range>(__r));
> }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> template<size_t _Nm>
> @@ -8844,6 +8846,8 @@ namespace views::__adaptor
> else
> return as_rvalue_view(std::forward<_Range>(__r));
> }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> inline constexpr _AsRvalue as_rvalue;
> @@ -9147,6 +9151,8 @@ namespace views::__adaptor
> constexpr auto
> operator() [[nodiscard]] (_Range&& __r) const
> { return enumerate_view<all_t<_Range>>(std::forward<_Range>(__r)); }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> inline constexpr _Enumerate enumerate;
> @@ -9253,6 +9259,8 @@ namespace views::__adaptor
> else
> return as_const_view(std::forward<_Range>(__r));
> }
> +
> + static constexpr bool _S_has_simple_call_op = true;
> };
>
> inline constexpr _AsConst as_const;
> --
> 2.43.0.367.g186b115d30
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-27 12:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17 2:36 [PATCH] libstdc++/ranges: Define _S_has_simple_call_op on newer adaptors Patrick Palka
2024-01-17 7:22 ` Jonathan Wakely
2024-03-27 12:46 ` Patrick Palka
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).