On Wed, 5 Mar 2025 at 11:06, Tomasz Kamiński wrote:
>
> Fix regression introduced by r14-8710-g65b4cba9d6a9ff
>
>         PR libstdc++/119121
>
> libstdc++-v3/ChangeLog:
>
>         * include/bits/ranges_util.h (__detail::__pair_like_convertible_from):
>         Use `_Tp` in `is_reference_v` check
>         * testsuite/std/ranges/subrange/tuple_like.cc: New tests for
>         pair-like conversion
> ---
> Testing x86_64. OK for master and 14?

OK for both if testing passes.

Thanks, and congrats on your first libstdc++ contribution!

If you want to you can add:
Reviewed-by: Jonathan Wakely <jwak...@redhat.com>
to the end of the git commit message (using git commit --amend) to
record who reviewed and/or approved it. There's no GCC policy about
doing this, it's entirely optional.


>
>  libstdc++-v3/include/bits/ranges_util.h       |  2 +-
>  .../std/ranges/subrange/tuple_like.cc         | 29 +++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/bits/ranges_util.h 
> b/libstdc++-v3/include/bits/ranges_util.h
> index 2f56b727e55..51024ecbebe 100644
> --- a/libstdc++-v3/include/bits/ranges_util.h
> +++ b/libstdc++-v3/include/bits/ranges_util.h
> @@ -244,7 +244,7 @@ namespace ranges
>
>      template<typename _Tp, typename _Up, typename _Vp>
>        concept __pair_like_convertible_from
> -       = !range<_Tp> && !is_reference_v<_Vp> && __pair_like<_Tp>
> +       = !range<_Tp> && !is_reference_v<_Tp> && __pair_like<_Tp>
>         && constructible_from<_Tp, _Up, _Vp>
>         && __convertible_to_non_slicing<_Up, tuple_element_t<0, _Tp>>
>         && convertible_to<_Vp, tuple_element_t<1, _Tp>>;
> diff --git a/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like.cc 
> b/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like.cc
> index 6d05eb3ef7d..80fe618642a 100644
> --- a/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/subrange/tuple_like.cc
> @@ -18,6 +18,8 @@
>  // { dg-do compile { target c++20 } }
>
>  #include <ranges>
> +#include <tuple>
> +#include <utility>
>
>  using S1 = std::ranges::subrange<int*>;
>  using S2 = std::ranges::subrange<long*, void*>;
> @@ -49,3 +51,30 @@ static_assert( std::same_as<decltype(std::get<1>(s2)), 
> void*> );
>  const S2 c2;
>  static_assert( std::same_as<decltype(std::get<0>(c2)), long*> );
>  static_assert( std::same_as<decltype(std::get<1>(c2)), void*> );
> +
> +std::pair<int*, int*> p1 = s1;
> +std::pair<long*, void*> p2 = s2;
> +std::tuple<int*, int*> t1 = s1;
> +std::tuple<long*, void*> t2 = s2;
> +
> +std::pair<int*, int*> const& p3 = s1;
> +std::tuple<int*, int*>&& t3 = s1;
> +
> +std::pair<int const*, int const*> p4 = s1;
> +std::tuple<int const*, void*> t4 = s1;
> +
> +static_assert( !std::convertible_to<std::ranges::subrange<int const*>, 
> std::pair<int*, int*>> );
> +static_assert( !std::convertible_to<std::ranges::subrange<int const*>, 
> std::tuple<int*, int*>> );
> +
> +static_assert( !std::convertible_to<std::ranges::subrange<int*>, 
> std::pair<long*, long*>> );
> +static_assert( !std::convertible_to<std::ranges::subrange<int*>, 
> std::tuple<int, int>> );
> +
> +struct B {};
> +struct D : B {};
> +
> +std::ranges::subrange<D*> sd;
> +std::pair<D*, D*> p5 = sd;
> +std::tuple<D const*, D const*> t5 = sd;
> +
> +static_assert( !std::convertible_to<std::ranges::subrange<D*>, std::pair<B*, 
> B*>> );
> +static_assert( !std::convertible_to<std::ranges::subrange<B*>, 
> std::tuple<D*, D*>> );
> --
> 2.48.1
>

Reply via email to