[3/3] libstdc++: Fix return type of empty zip/adjacent_transform [PR106803]

Message ID 20220909172446.1546805-3-ppalka@redhat.com
State New, archived
Headers
Series [1/3] libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766] |

Commit Message

Patrick Palka Sept. 9, 2022, 5:24 p.m. UTC
  Tested on x86_64-pc-linux-gnu, does this series look OK for trunk?

	PR libstdc++/106803

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::_ZipTransform::operator()): Fix
	return type in the empty case.
	(views::_AdjacentTransform::operator()): Likewise.
---
 libstdc++-v3/include/std/ranges | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Jonathan Wakely Sept. 9, 2022, 6:29 p.m. UTC | #1
On Fri, 9 Sep 2022, 18:27 Patrick Palka via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> Tested on x86_64-pc-linux-gnu, does this series look OK for trunk?
>


All three are OK, thanks.


>         PR libstdc++/106803
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/ranges (views::_ZipTransform::operator()): Fix
>         return type in the empty case.
>         (views::_AdjacentTransform::operator()): Likewise.
> ---
>  libstdc++-v3/include/std/ranges | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/ranges
> b/libstdc++-v3/include/std/ranges
> index 37ad80ad3de..20eb4e82ac8 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -5071,7 +5071,7 @@ namespace views::__adaptor
>         operator() [[nodiscard]] (_Fp&& __f, _Ts&&... __ts) const
>         {
>           if constexpr (sizeof...(_Ts) == 0)
> -           return views::empty<decay_t<invoke_result_t<_Fp>>>;
> +           return views::empty<decay_t<invoke_result_t<decay_t<_Fp>&>>>;
>           else
>             return zip_transform_view(std::forward<_Fp>(__f),
> std::forward<_Ts>(__ts)...);
>         }
> @@ -5762,7 +5762,7 @@ namespace views::__adaptor
>           operator() [[nodiscard]] (_Range&& __r, _Fp&& __f) const
>           {
>             if constexpr (_Nm == 0)
> -             return views::empty<tuple<>>;
> +             return zip_transform(std::forward<_Fp>(__f));
>             else
>               return adjacent_transform_view<all_t<_Range>, decay_t<_Fp>,
> _Nm>
>                 (std::forward<_Range>(__r), std::forward<_Fp>(__f));
> --
> 2.37.3.518.g79f2338b37
>
>
  

Patch

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 37ad80ad3de..20eb4e82ac8 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -5071,7 +5071,7 @@  namespace views::__adaptor
 	operator() [[nodiscard]] (_Fp&& __f, _Ts&&... __ts) const
 	{
 	  if constexpr (sizeof...(_Ts) == 0)
-	    return views::empty<decay_t<invoke_result_t<_Fp>>>;
+	    return views::empty<decay_t<invoke_result_t<decay_t<_Fp>&>>>;
 	  else
 	    return zip_transform_view(std::forward<_Fp>(__f), std::forward<_Ts>(__ts)...);
 	}
@@ -5762,7 +5762,7 @@  namespace views::__adaptor
 	  operator() [[nodiscard]] (_Range&& __r, _Fp&& __f) const
 	  {
 	    if constexpr (_Nm == 0)
-	      return views::empty<tuple<>>;
+	      return zip_transform(std::forward<_Fp>(__f));
 	    else
 	      return adjacent_transform_view<all_t<_Range>, decay_t<_Fp>, _Nm>
 		(std::forward<_Range>(__r), std::forward<_Fp>(__f));