Android defaults to pic (#123955)
[llvm-project.git] / libcxx / include / __iterator / move_sentinel.h
blob4a2a09ef0611d248fe598646abe1e4201a817237
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_MOVE_SENTINEL_H
10 #define _LIBCPP___ITERATOR_MOVE_SENTINEL_H
12 #include <__concepts/assignable.h>
13 #include <__concepts/convertible_to.h>
14 #include <__concepts/semiregular.h>
15 #include <__config>
16 #include <__utility/move.h>
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 # pragma GCC system_header
20 #endif
22 _LIBCPP_PUSH_MACROS
23 #include <__undef_macros>
25 _LIBCPP_BEGIN_NAMESPACE_STD
27 #if _LIBCPP_STD_VER >= 20
29 template <semiregular _Sent>
30 class _LIBCPP_TEMPLATE_VIS move_sentinel {
31 public:
32 _LIBCPP_HIDE_FROM_ABI move_sentinel() = default;
34 _LIBCPP_HIDE_FROM_ABI constexpr explicit move_sentinel(_Sent __s) : __last_(std::move(__s)) {}
36 template <class _S2>
37 requires convertible_to<const _S2&, _Sent>
38 _LIBCPP_HIDE_FROM_ABI constexpr move_sentinel(const move_sentinel<_S2>& __s) : __last_(__s.base()) {}
40 template <class _S2>
41 requires assignable_from<_Sent&, const _S2&>
42 _LIBCPP_HIDE_FROM_ABI constexpr move_sentinel& operator=(const move_sentinel<_S2>& __s) {
43 __last_ = __s.base();
44 return *this;
47 _LIBCPP_HIDE_FROM_ABI constexpr _Sent base() const { return __last_; }
49 private:
50 _Sent __last_ = _Sent();
53 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_sentinel);
55 #endif // _LIBCPP_STD_VER >= 20
57 _LIBCPP_END_NAMESPACE_STD
59 _LIBCPP_POP_MACROS
61 #endif // _LIBCPP___ITERATOR_MOVE_SENTINEL_H