Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:53

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___ITERATOR_PROJECTED_H
0011 #define _LIBCPP___ITERATOR_PROJECTED_H
0012 
0013 #include <__config>
0014 #include <__iterator/concepts.h>
0015 #include <__iterator/incrementable_traits.h> // iter_difference_t
0016 #include <__type_traits/remove_cvref.h>
0017 
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #  pragma GCC system_header
0020 #endif
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 #if _LIBCPP_STD_VER >= 20
0025 
0026 template <class _It, class _Proj>
0027 struct __projected_impl {
0028   struct __type {
0029     using __primary_template _LIBCPP_NODEBUG     = __type;
0030     using __projected_iterator _LIBCPP_NODEBUG   = _It;
0031     using __projected_projection _LIBCPP_NODEBUG = _Proj;
0032 
0033     using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
0034     indirect_result_t<_Proj&, _It> operator*() const; // not defined
0035   };
0036 };
0037 
0038 template <weakly_incrementable _It, class _Proj>
0039 struct __projected_impl<_It, _Proj> {
0040   struct __type {
0041     using __primary_template _LIBCPP_NODEBUG     = __type;
0042     using __projected_iterator _LIBCPP_NODEBUG   = _It;
0043     using __projected_projection _LIBCPP_NODEBUG = _Proj;
0044 
0045     using value_type      = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
0046     using difference_type = iter_difference_t<_It>;
0047     indirect_result_t<_Proj&, _It> operator*() const; // not defined
0048   };
0049 };
0050 
0051 // Note that we implement std::projected in a way that satisfies P2538R1 even in standard
0052 // modes before C++26 to avoid breaking the ABI between standard modes (even though ABI
0053 // breaks with std::projected are expected to have essentially no impact).
0054 template <indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>
0055 using projected = typename __projected_impl<_It, _Proj>::__type;
0056 
0057 #endif // _LIBCPP_STD_VER >= 20
0058 
0059 _LIBCPP_END_NAMESPACE_STD
0060 
0061 #endif // _LIBCPP___ITERATOR_PROJECTED_H