[libcxx-commits] [PATCH] D150493: [libc++] Add concepts that ensure a given iterator meets the syntactic requirements
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 7 08:17:37 PDT 2023
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.
LGTM w/ comments
================
Comment at: libcxx/include/__iterator/cpp17_iterator_concepts.h:48
+template <class _Tp>
+concept __cpp17_copy_assignable = __cpp17_move_assignable<_Tp> && requires(_Tp __lhs, _Tp __rhs) {
+ { __lhs = __rhs } -> same_as<_Tp&>;
----------------
Per http://eel.is/c++draft/utility.arg.requirements#1.6, `a = b` must work if `b` is const. Needs a test too.
================
Comment at: libcxx/include/__iterator/cpp17_iterator_concepts.h:55-56
+
+template <class _Iter>
+concept __cpp17_equality_comparable = requires(_Iter __lhs, _Iter __rhs) {
+ { __lhs == __rhs } -> __boolean_testable;
----------------
I'd suggest we use `_Tp` instead of `_Iter` here, this isn't limited to iterators.
================
Comment at: libcxx/include/__iterator/cpp17_iterator_concepts.h:69
+ __cpp17_copy_constructible<_Iter> && __cpp17_copy_assignable<_Iter> && __cpp17_destructible<_Iter> &&
+ (is_signed_v<__iter_diff_t<_Iter>> || is_void_v<__iter_diff_t<_Iter>>)&&requires(_Iter __iter) {
+ { *__iter };
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150493/new/
https://reviews.llvm.org/D150493
More information about the libcxx-commits
mailing list