Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement move_sentinel and C++20 move_iterator.
Differential Revision: https://reviews.llvm.org/D117656
- Loading branch information
Showing
25 changed files
with
1,295 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ITERATOR_MOVE_SENTINEL_H | ||
#define _LIBCPP___ITERATOR_MOVE_SENTINEL_H | ||
|
||
#include <__concepts/assignable.h> | ||
#include <__concepts/convertible_to.h> | ||
#include <__concepts/semiregular.h> | ||
#include <__config> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | ||
|
||
template <semiregular _Sent> | ||
class _LIBCPP_TEMPLATE_VIS move_sentinel | ||
{ | ||
public: | ||
_LIBCPP_HIDE_FROM_ABI | ||
move_sentinel() = default; | ||
|
||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
explicit move_sentinel(_Sent __s) : __last_(_VSTD::move(__s)) {} | ||
|
||
template <class _S2> | ||
requires convertible_to<const _S2&, _Sent> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
move_sentinel(const move_sentinel<_S2>& __s) : __last_(__s.base()) {} | ||
|
||
template <class _S2> | ||
requires assignable_from<_Sent&, const _S2&> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
move_sentinel& operator=(const move_sentinel<_S2>& __s) | ||
{ __last_ = __s.base(); return *this; } | ||
|
||
constexpr _Sent base() const { return __last_; } | ||
|
||
private: | ||
_Sent __last_ = _Sent(); | ||
}; | ||
|
||
#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ITERATOR_MOVE_SENTINEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
libcxx/test/libcxx/diagnostics/detail.headers/iterator/move_sentinel.module.verify.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// REQUIRES: modules-build | ||
|
||
// WARNING: This test was generated by 'generate_private_header_tests.py' | ||
// and should not be edited manually. | ||
|
||
// expected-error@*:* {{use of private header from outside its module: '__iterator/move_sentinel.h'}} | ||
#include <__iterator/move_sentinel.h> |
Oops, something went wrong.