[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __iterator / iterator_with_data.h
blobafdc0a4e12e21c1b63ab2c9a11da57b16ee68feb
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H
10 #define _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H
12 #include <__compare/compare_three_way_result.h>
13 #include <__compare/three_way_comparable.h>
14 #include <__config>
15 #include <__iterator/concepts.h>
16 #include <__iterator/incrementable_traits.h>
17 #include <__iterator/iter_move.h>
18 #include <__iterator/iter_swap.h>
19 #include <__iterator/iterator_traits.h>
20 #include <__iterator/readable_traits.h>
21 #include <__utility/move.h>
23 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24 # pragma GCC system_header
25 #endif
27 _LIBCPP_PUSH_MACROS
28 #include <__undef_macros>
30 #if _LIBCPP_STD_VER >= 20
32 _LIBCPP_BEGIN_NAMESPACE_STD
34 template <forward_iterator _Iterator, class _Data>
35 class __iterator_with_data {
36 _Iterator __iter_{};
37 _Data __data_{};
39 public:
40 using value_type = iter_value_t<_Iterator>;
41 using difference_type = iter_difference_t<_Iterator>;
43 _LIBCPP_HIDE_FROM_ABI __iterator_with_data() = default;
45 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data(_Iterator __iter, _Data __data)
46 : __iter_(std::move(__iter)), __data_(std::move(__data)) {}
48 constexpr _LIBCPP_HIDE_FROM_ABI _Iterator __get_iter() const { return __iter_; }
50 constexpr _LIBCPP_HIDE_FROM_ABI _Data __get_data() && { return std::move(__data_); }
52 friend constexpr _LIBCPP_HIDE_FROM_ABI bool
53 operator==(const __iterator_with_data& __lhs, const __iterator_with_data& __rhs) {
54 return __lhs.__iter_ == __rhs.__iter_;
57 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data& operator++() {
58 ++__iter_;
59 return *this;
62 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data operator++(int) {
63 auto __tmp = *this;
64 __iter_++;
65 return __tmp;
68 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data& operator--()
69 requires bidirectional_iterator<_Iterator>
71 --__iter_;
72 return *this;
75 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data operator--(int)
76 requires bidirectional_iterator<_Iterator>
78 auto __tmp = *this;
79 --__iter_;
80 return __tmp;
83 constexpr _LIBCPP_HIDE_FROM_ABI iter_reference_t<_Iterator> operator*() const { return *__iter_; }
85 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iterator>
86 iter_move(const __iterator_with_data& __iter) noexcept(noexcept(ranges::iter_move(__iter.__iter_))) {
87 return ranges::iter_move(__iter.__iter_);
90 _LIBCPP_HIDE_FROM_ABI friend constexpr void
91 iter_swap(const __iterator_with_data& __lhs,
92 const __iterator_with_data& __rhs) noexcept(noexcept(ranges::iter_swap(__lhs.__iter_, __rhs.__iter_)))
93 requires indirectly_swappable<_Iterator>
95 return ranges::iter_swap(__lhs.__data_, __rhs.__iter_);
99 _LIBCPP_END_NAMESPACE_STD
101 #endif // _LIBCPP_STD_VER >= 20
103 _LIBCPP_POP_MACROS
105 #endif // _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H