2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ITERATOR_PROJECTED_H
11 #define _LIBCPP___ITERATOR_PROJECTED_H
14 #include <__iterator/concepts.h>
15 #include <__iterator/incrementable_traits.h> // iter_difference_t
16 #include <__type_traits/remove_cvref.h>
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 # pragma GCC system_header
22 _LIBCPP_BEGIN_NAMESPACE_STD
24 #if _LIBCPP_STD_VER >= 20
26 template <class _It
, class _Proj
>
27 struct __projected_impl
{
29 using __primary_template
= __type
;
30 using __projected_iterator
= _It
;
31 using __projected_projection
= _Proj
;
33 using value_type
= remove_cvref_t
<indirect_result_t
<_Proj
&, _It
>>;
34 indirect_result_t
<_Proj
&, _It
> operator*() const; // not defined
38 template <weakly_incrementable _It
, class _Proj
>
39 struct __projected_impl
<_It
, _Proj
> {
41 using __primary_template
= __type
;
42 using __projected_iterator
= _It
;
43 using __projected_projection
= _Proj
;
45 using value_type
= remove_cvref_t
<indirect_result_t
<_Proj
&, _It
>>;
46 using difference_type
= iter_difference_t
<_It
>;
47 indirect_result_t
<_Proj
&, _It
> operator*() const; // not defined
51 // Note that we implement std::projected in a way that satisfies P2538R1 even in standard
52 // modes before C++26 to avoid breaking the ABI between standard modes (even though ABI
53 // breaks with std::projected are expected to have essentially no impact).
54 template <indirectly_readable _It
, indirectly_regular_unary_invocable
<_It
> _Proj
>
55 using projected
= typename __projected_impl
<_It
, _Proj
>::__type
;
57 #endif // _LIBCPP_STD_VER >= 20
59 _LIBCPP_END_NAMESPACE_STD
61 #endif // _LIBCPP___ITERATOR_PROJECTED_H