| 1 | // Copyright (C) 2020-2025 Free Software Foundation, Inc. |
| 2 | // |
| 3 | // This file is part of the GNU ISO C++ Library. This library is free |
| 4 | // software; you can redistribute it and/or modify it under the |
| 5 | // terms of the GNU General Public License as published by the |
| 6 | // Free Software Foundation; either version 3, or (at your option) |
| 7 | // any later version. |
| 8 | |
| 9 | // This library is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | |
| 14 | // You should have received a copy of the GNU General Public License along |
| 15 | // with this library; see the file COPYING3. If not see |
| 16 | // <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | // { dg-do compile { target c++20 } } |
| 19 | |
| 20 | #include <iterator> |
| 21 | |
| 22 | using namespace std; |
| 23 | |
| 24 | // Define our own of version of indirectly_readable_impl here, |
| 25 | // to check the use of iter_move even if the real concept in |
| 26 | // <bits/iterator_concepts.h> no longer uses iter_move. |
| 27 | template<class In> |
| 28 | concept indirectly_readable_impl |
| 29 | = requires(const In in) |
| 30 | { |
| 31 | typename iter_value_t<In>; |
| 32 | typename iter_reference_t<In>; |
| 33 | typename iter_rvalue_reference_t<In>; |
| 34 | { *in } -> same_as<iter_reference_t<In>>; |
| 35 | { ranges::iter_move(in) } -> same_as<iter_rvalue_reference_t<In>>; |
| 36 | }; |
| 37 | |
| 38 | template<class T> requires indirectly_readable_impl<projected<T*, identity>> |
| 39 | void algo(T) |
| 40 | { } |
| 41 | |
| 42 | void |
| 43 | test01() |
| 44 | { |
| 45 | // PR libstdc++/92894 |
| 46 | // Verify that the use of range::iter_move above doesn't cause odr-use of |
| 47 | // projected<local-class-type, identity>::operator* (which is not defined). |
| 48 | struct X { }; |
| 49 | X a; |
| 50 | algo(a); |
| 51 | } |