[libcxx-commits] [libcxx] 148c19a - [libc++] [test] Format some C++20 iterator_traits tests. NFCI.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 25 08:13:32 PDT 2021
Author: Arthur O'Dwyer
Date: 2021-05-25T11:12:36-04:00
New Revision: 148c19a5b52b2c971573904911f6c90c72c45fe9
URL: https://github.com/llvm/llvm-project/commit/148c19a5b52b2c971573904911f6c90c72c45fe9
DIFF: https://github.com/llvm/llvm-project/commit/148c19a5b52b2c971573904911f6c90c72c45fe9.diff
LOG: [libc++] [test] Format some C++20 iterator_traits tests. NFCI.
cxx20_iterator_traits.compile.pass.cpp actually depends on
implementation details of libc++, which is not great;
but I just left a comment and moved on.
Added:
Modified:
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp
libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp
libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/incrementable_traits.compile.pass.cpp
libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/iter_difference_t.pass.cpp
libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/readable.traits/indirectly_readable_traits.compile.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
index 19417c20fcde..2bc7f8ecb95e 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_bidirectional_iterator.compile.pass.cpp
@@ -35,13 +35,10 @@
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_proxy_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_input_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_proxy_input_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_proxy_input_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_forward_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_bidirectional_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_random_access_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_bidirectional_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<iterator_traits_cpp17_random_access_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<int*>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<int const*>);
@@ -52,8 +49,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<int
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::array<int, 10>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::array<int, 10>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::array<int, 10>::reverse_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::array<int, 10>::const_reverse_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::array<int, 10>::const_reverse_iterator>);
// <deque>
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::deque<int>::iterator>);
@@ -64,8 +60,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std:
// <filesystem>
#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::filesystem::directory_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::filesystem::recursive_directory_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::filesystem::recursive_directory_iterator>);
#endif
// <forward_list>
@@ -73,13 +68,10 @@ static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::forward_list<int>::const_iterator>);
// <iterator>
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::back_insert_iterator<std::vector<int> > >);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::front_insert_iterator<std::vector<int> > >);
-static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::insert_iterator<std::vector<int> > >);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::move_iterator<std::vector<int>::iterator> >);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::back_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::front_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::move_iterator<int*>>);
// <list>
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::list<int>::iterator>);
@@ -91,14 +83,12 @@ static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std:
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::map<int, int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::map<int, int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::map<int, int>::reverse_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::map<int, int>::const_reverse_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::map<int, int>::const_reverse_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multimap<int, int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multimap<int, int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multimap<int, int>::reverse_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multimap<int, int>::const_reverse_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multimap<int, int>::const_reverse_iterator>);
// <set>
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::set<int>::iterator>);
@@ -109,8 +99,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std:
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multiset<int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multiset<int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multiset<int>::reverse_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multiset<int>::const_reverse_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::multiset<int>::const_reverse_iterator>);
// <string>
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::string::iterator>);
@@ -126,36 +115,25 @@ static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std:
// <unordered_map>
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_map<int, int>::iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_map<int, int>::const_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_map<int, int>::local_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_map<int, int>::const_local_iterator>);
-
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multimap<int, int>::iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multimap<int, int>::const_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multimap<int, int>::local_iterator>);
-static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<
- std::unordered_multimap<int, int>::const_local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_map<int, int>::const_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_map<int, int>::local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_map<int, int>::const_local_iterator>);
+
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multimap<int, int>::iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multimap<int, int>::const_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multimap<int, int>::local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multimap<int, int>::const_local_iterator>);
// <unordered_set>
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_set<int>::iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_set<int>::const_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_set<int>::local_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_set<int>::const_local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_set<int>::const_local_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multiset<int>::iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multiset<int>::const_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multiset<int>::local_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multiset<int>::const_local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multiset<int>::const_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multiset<int>::local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::unordered_multiset<int>::const_local_iterator>);
// <vector>
static_assert(std::__iterator_traits_detail::__cpp17_bidirectional_iterator<std::vector<int>::iterator>);
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
index 3f628e794cfd..d1f96f84937e 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_forward_iterator.compile.pass.cpp
@@ -68,11 +68,10 @@ static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::forwa
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::forward_list<int>::const_iterator>);
// <iterator>
-static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::back_insert_iterator<std::vector<int> > >);
-static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::front_insert_iterator<std::vector<int> > >);
-static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::insert_iterator<std::vector<int> > >);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_forward_iterator<std::move_iterator<std::vector<int>::iterator> >);
+static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::back_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::front_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_forward_iterator<std::move_iterator<int*>>);
// <list>
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::list<int>::iterator>);
@@ -118,16 +117,12 @@ static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::strin
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_map<int, int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_map<int, int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_map<int, int>::local_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_map<int, int>::const_local_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_map<int, int>::const_local_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multimap<int, int>::iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multimap<int, int>::const_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multimap<int, int>::local_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multimap<int, int>::const_local_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multimap<int, int>::const_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multimap<int, int>::local_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multimap<int, int>::const_local_iterator>);
// <unordered_set>
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_set<int>::iterator>);
@@ -138,8 +133,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unord
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multiset<int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multiset<int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multiset<int>::local_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multiset<int>::const_local_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::unordered_multiset<int>::const_local_iterator>);
// <vector>
static_assert(std::__iterator_traits_detail::__cpp17_forward_iterator<std::vector<int>::iterator>);
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp
index 99994da800c5..d816e45c3dbd 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_input_iterator.compile.pass.cpp
@@ -68,10 +68,10 @@ static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::forward
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::forward_list<int>::const_iterator>);
// <iterator>
-static_assert(!std::__iterator_traits_detail::__cpp17_input_iterator<std::back_insert_iterator<std::vector<int> > >);
-static_assert(!std::__iterator_traits_detail::__cpp17_input_iterator<std::front_insert_iterator<std::vector<int> > >);
-static_assert(!std::__iterator_traits_detail::__cpp17_input_iterator<std::insert_iterator<std::vector<int> > >);
-static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::move_iterator<std::vector<int>::iterator> >);
+static_assert(!std::__iterator_traits_detail::__cpp17_input_iterator<std::back_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_input_iterator<std::front_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_input_iterator<std::insert_iterator<std::vector<int>>>);
+static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::move_iterator<int*>>);
// <list>
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::list<int>::iterator>);
@@ -117,14 +117,12 @@ static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::string_
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_map<int, int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_map<int, int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_map<int, int>::local_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_map<int, int>::const_local_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_map<int, int>::const_local_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multimap<int, int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multimap<int, int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multimap<int, int>::local_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multimap<int, int>::const_local_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multimap<int, int>::const_local_iterator>);
// <unordered_set>
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_set<int>::iterator>);
@@ -135,8 +133,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unorder
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multiset<int>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multiset<int>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multiset<int>::local_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multiset<int>::const_local_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::unordered_multiset<int>::const_local_iterator>);
// <vector>
static_assert(std::__iterator_traits_detail::__cpp17_input_iterator<std::vector<int>::iterator>);
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp
index 040c7051ef67..d0b7f240f440 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_iterator.compile.pass.cpp
@@ -68,10 +68,10 @@ static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::forward_list<
static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::forward_list<int>::const_iterator>);
// <iterator>
-static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::back_insert_iterator<std::vector<int> > >);
-static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::front_insert_iterator<std::vector<int> > >);
-static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::insert_iterator<std::vector<int> > >);
-static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::move_iterator<std::vector<int>::iterator> >);
+static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::back_insert_iterator<std::vector<int>>>);
+static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::front_insert_iterator<std::vector<int>>>);
+static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::insert_iterator<std::vector<int>>>);
+static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::move_iterator<int*>>);
// <list>
static_assert(std::__iterator_traits_detail::__cpp17_iterator<std::list<int>::iterator>);
diff --git a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
index d024f43b6507..2214607d1bfe 100644
--- a/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
+++ b/libcxx/test/libcxx/iterators/iterator.requirements/iterator.assoc.types/iterator.traits/legacy_random_access_iterator.compile.pass.cpp
@@ -35,13 +35,10 @@
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_proxy_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_input_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_proxy_input_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_proxy_input_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_forward_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_bidirectional_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_random_access_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_bidirectional_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<iterator_traits_cpp17_random_access_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<int*>);
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<int const*>);
@@ -52,8 +49,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<int
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::array<int, 10>::iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::array<int, 10>::const_iterator>);
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::array<int, 10>::reverse_iterator>);
-static_assert(
- std::__iterator_traits_detail::__cpp17_random_access_iterator<std::array<int, 10>::const_reverse_iterator>);
+static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::array<int, 10>::const_reverse_iterator>);
// <deque>
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::deque<int>::iterator>);
@@ -64,8 +60,7 @@ static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std:
// <filesystem>
#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::filesystem::directory_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::filesystem::recursive_directory_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::filesystem::recursive_directory_iterator>);
#endif
// <forward_list>
@@ -73,13 +68,10 @@ static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::forward_list<int>::const_iterator>);
// <iterator>
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::back_insert_iterator<std::vector<int> > >);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::front_insert_iterator<std::vector<int> > >);
-static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::insert_iterator<std::vector<int> > >);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::move_iterator<std::vector<int>::iterator> >);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::back_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::front_insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::insert_iterator<std::vector<int>>>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::move_iterator<int*>>);
// <list>
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::list<int>::iterator>);
@@ -91,15 +83,12 @@ static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::map<int, int>::iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::map<int, int>::const_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::map<int, int>::reverse_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::map<int, int>::const_reverse_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::map<int, int>::const_reverse_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multimap<int, int>::iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multimap<int, int>::const_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multimap<int, int>::reverse_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multimap<int, int>::const_reverse_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multimap<int, int>::reverse_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multimap<int, int>::const_reverse_iterator>);
// <set>
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::set<int>::iterator>);
@@ -110,8 +99,7 @@ static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multiset<int>::iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multiset<int>::const_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multiset<int>::reverse_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multiset<int>::const_reverse_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::multiset<int>::const_reverse_iterator>);
// <string>
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::string::iterator>);
@@ -127,36 +115,25 @@ static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std:
// <unordered_map>
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_map<int, int>::iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_map<int, int>::const_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_map<int, int>::local_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_map<int, int>::const_local_iterator>);
-
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multimap<int, int>::iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multimap<int, int>::const_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multimap<int, int>::local_iterator>);
-static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<
- std::unordered_multimap<int, int>::const_local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_map<int, int>::const_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_map<int, int>::local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_map<int, int>::const_local_iterator>);
+
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multimap<int, int>::iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multimap<int, int>::const_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multimap<int, int>::local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multimap<int, int>::const_local_iterator>);
// <unordered_set>
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_set<int>::iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_set<int>::const_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_set<int>::local_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_set<int>::const_local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_set<int>::const_local_iterator>);
static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multiset<int>::iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multiset<int>::const_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multiset<int>::local_iterator>);
-static_assert(
- !std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multiset<int>::const_local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multiset<int>::const_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multiset<int>::local_iterator>);
+static_assert(!std::__iterator_traits_detail::__cpp17_random_access_iterator<std::unordered_multiset<int>::const_local_iterator>);
// <vector>
static_assert(std::__iterator_traits_detail::__cpp17_random_access_iterator<std::vector<int>::iterator>);
diff --git a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp
index 701ea8e5b6c7..8a0ae891f4f7 100644
--- a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/cxx20_iterator_traits.compile.pass.cpp
@@ -50,147 +50,170 @@ constexpr bool has_iterator_concept_v = requires {
typename Traits::iterator_concept;
};
-// Standard types.
+template <class Iter, class Category, class Diff = void>
+constexpr bool testIOIterator() {
+ using Traits = std::iterator_traits<Iter>;
+ static_assert(std::same_as<typename Traits::iterator_category, Category>);
+ static_assert(std::same_as<typename Traits::value_type, void>);
+ static_assert(std::same_as<typename Traits::
diff erence_type, Diff>);
+ static_assert(std::same_as<typename Traits::reference, void>);
+ static_assert(std::same_as<typename Traits::pointer, void>);
+ static_assert(!has_iterator_concept_v<Traits>);
+
+ return true;
+}
+
+template <class Iter, class ValueType, class Category>
+constexpr bool testConstWithoutConcept() {
+ using Traits = std::iterator_traits<Iter>;
+ static_assert(std::same_as<typename Traits::iterator_category, Category>);
+ static_assert(std::same_as<typename Traits::value_type, ValueType>);
+ static_assert(std::same_as<typename Traits::
diff erence_type, std::ptr
diff _t>);
+ static_assert(std::same_as<typename Traits::reference, const ValueType&>);
+ static_assert(std::same_as<typename Traits::pointer, const ValueType*>);
+ static_assert(!has_iterator_concept_v<Traits>);
-template <class Iter, class ValueType, class Category, class IterConcept = void>
-constexpr bool testStdlibIteratorConst() {
+ return true;
+}
+
+template <class Iter, class ValueType, class Category, class IterConcept>
+constexpr bool testConstWithConcept() {
using Traits = std::iterator_traits<Iter>;
static_assert(std::same_as<typename Traits::iterator_category, Category>);
static_assert(std::same_as<typename Traits::value_type, ValueType>);
static_assert(std::same_as<typename Traits::
diff erence_type, std::ptr
diff _t>);
static_assert(std::same_as<typename Traits::reference, const ValueType&>);
static_assert(std::same_as<typename Traits::pointer, const ValueType*>);
- if constexpr (std::same_as<IterConcept, void>)
- static_assert(!has_iterator_concept_v<Traits>);
- else
- static_assert(std::same_as<typename Traits::iterator_concept, IterConcept>);
+ static_assert(std::same_as<typename Traits::iterator_concept, IterConcept>);
return true;
}
-template <class Iter, class ValueType, class Category, class IterConcept = void>
-constexpr bool testStdlibIterator() {
+template <class Iter, class ValueType, class Category>
+constexpr bool testWithoutConcept() {
using Traits = std::iterator_traits<Iter>;
static_assert(std::same_as<typename Traits::iterator_category, Category>);
static_assert(std::same_as<typename Traits::value_type, ValueType>);
static_assert(std::same_as<typename Traits::
diff erence_type, std::ptr
diff _t>);
static_assert(std::same_as<typename Traits::reference, ValueType&>);
static_assert(std::same_as<typename Traits::pointer, ValueType*>);
- if constexpr (std::same_as<IterConcept, void>)
- static_assert(!has_iterator_concept_v<Traits>);
- else
- static_assert(std::same_as<typename Traits::iterator_concept, IterConcept>);
+ static_assert(!has_iterator_concept_v<Traits>);
return true;
}
-template <class Iter, class ValueType, class Category, class Diff = void>
-requires std::same_as<ValueType, void> constexpr bool testStdlibIterator() {
+template <class Iter, class ValueType, class Category, class IterConcept>
+constexpr bool testWithConcept() {
using Traits = std::iterator_traits<Iter>;
static_assert(std::same_as<typename Traits::iterator_category, Category>);
- static_assert(std::same_as<typename Traits::value_type, void>);
- static_assert(std::same_as<typename Traits::
diff erence_type, Diff>);
- static_assert(std::same_as<typename Traits::reference, void>);
- static_assert(std::same_as<typename Traits::pointer, void>);
- static_assert(!has_iterator_concept_v<Traits>);
+ static_assert(std::same_as<typename Traits::value_type, ValueType>);
+ static_assert(std::same_as<typename Traits::
diff erence_type, std::ptr
diff _t>);
+ static_assert(std::same_as<typename Traits::reference, ValueType&>);
+ static_assert(std::same_as<typename Traits::pointer, ValueType*>);
+ static_assert(std::same_as<typename Traits::iterator_concept, IterConcept>);
return true;
}
-template <class Iter, class ValueType, class DiffType, class RefType, class PtrType, class Category,
- class IterConcept = void>
-constexpr bool testStdlibIterator() {
+template <class Iter, class ValueType, class DiffType, class RefType, class PtrType, class Category>
+constexpr bool testWithoutConcept() {
using Traits = std::iterator_traits<Iter>;
static_assert(std::same_as<typename Traits::iterator_category, Category>);
static_assert(std::same_as<typename Traits::value_type, ValueType>);
static_assert(std::same_as<typename Traits::
diff erence_type, DiffType>);
static_assert(std::same_as<typename Traits::reference, RefType>);
static_assert(std::same_as<typename Traits::pointer, PtrType>);
- if constexpr (std::same_as<IterConcept, void>)
- static_assert(!has_iterator_concept_v<Traits>);
- else
- static_assert(std::same_as<typename Traits::iterator_concept, IterConcept>);
+ static_assert(!has_iterator_concept_v<Traits>);
return true;
}
-template <class T, class... Args>
-constexpr bool testBothStdlibIterators() {
- static_assert(testStdlibIteratorConst<typename T::const_iterator, Args...>());
- static_assert(testStdlibIterator<typename T::iterator, Args...>());
+template <class Iter, class ValueType, class DiffType, class RefType, class PtrType, class Category, class IterConcept>
+constexpr bool testWithConcept() {
+ using Traits = std::iterator_traits<Iter>;
+ static_assert(std::same_as<typename Traits::iterator_category, Category>);
+ static_assert(std::same_as<typename Traits::value_type, ValueType>);
+ static_assert(std::same_as<typename Traits::
diff erence_type, DiffType>);
+ static_assert(std::same_as<typename Traits::reference, RefType>);
+ static_assert(std::same_as<typename Traits::pointer, PtrType>);
+ static_assert(std::same_as<typename Traits::iterator_concept, IterConcept>);
return true;
}
-static_assert(testBothStdlibIterators<std::vector<int>, int, std::random_access_iterator_tag>());
-static_assert(testBothStdlibIterators<std::string, char, std::random_access_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::string_view::iterator, char, std::random_access_iterator_tag,
- std::contiguous_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::string_view::const_iterator, char, std::random_access_iterator_tag,
- std::contiguous_iterator_tag>());
-static_assert(
- testBothStdlibIterators<std::array<int, 10>, int, std::random_access_iterator_tag, std::contiguous_iterator_tag>());
-static_assert(testBothStdlibIterators<std::deque<int>, int, std::random_access_iterator_tag>());
+// Standard types.
+
+// These tests depend on implementation details of libc++,
+// e.g. that std::array::iterator is a raw pointer type but std::string::iterator is not.
+// The Standard does not specify whether iterator_traits<It>::iterator_concept exists for any particular non-pointer type.
+//
+static_assert(testWithConcept<std::array<int, 10>::iterator, int, std::random_access_iterator_tag, std::contiguous_iterator_tag>());
+static_assert(testConstWithConcept<std::array<int, 10>::const_iterator, int, std::random_access_iterator_tag, std::contiguous_iterator_tag>());
+static_assert(testWithoutConcept<std::string::iterator, char, std::random_access_iterator_tag>());
+static_assert(testConstWithoutConcept<std::string::const_iterator, char, std::random_access_iterator_tag>());
+static_assert(testConstWithConcept<std::string_view::iterator, char, std::random_access_iterator_tag, std::contiguous_iterator_tag>());
+static_assert(testConstWithConcept<std::string_view::const_iterator, char, std::random_access_iterator_tag, std::contiguous_iterator_tag>());
+static_assert(testWithoutConcept<std::vector<int>::iterator, int, std::random_access_iterator_tag>());
+static_assert(testConstWithoutConcept<std::vector<int>::const_iterator, int, std::random_access_iterator_tag>());
+
+static_assert(testWithoutConcept<std::deque<int>::iterator, int, std::random_access_iterator_tag>());
+static_assert(testConstWithoutConcept<std::deque<int>::const_iterator, int, std::random_access_iterator_tag>());
+static_assert(testWithoutConcept<std::forward_list<int>::iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::forward_list<int>::const_iterator, int, std::forward_iterator_tag>());
+static_assert(testWithoutConcept<std::list<int>::iterator, int, std::bidirectional_iterator_tag>());
+static_assert(testConstWithoutConcept<std::list<int>::const_iterator, int, std::bidirectional_iterator_tag>());
+
+static_assert(testWithoutConcept<std::map<int, int>::iterator, std::pair<const int, int>, std::bidirectional_iterator_tag>());
+static_assert(testConstWithoutConcept<std::map<int, int>::const_iterator, std::pair<const int, int>, std::bidirectional_iterator_tag>());
+static_assert(testWithoutConcept<std::multimap<int, int>::iterator, std::pair<const int, int>, std::bidirectional_iterator_tag>());
+static_assert(testConstWithoutConcept<std::multimap<int, int>::const_iterator, std::pair<const int, int>, std::bidirectional_iterator_tag>());
+
+static_assert(testConstWithoutConcept<std::set<int>::iterator, int, std::bidirectional_iterator_tag>());
+static_assert(testConstWithoutConcept<std::set<int>::const_iterator, int, std::bidirectional_iterator_tag>());
+static_assert(testConstWithoutConcept<std::multiset<int>::iterator, int, std::bidirectional_iterator_tag>());
+static_assert(testConstWithoutConcept<std::multiset<int>::const_iterator, int, std::bidirectional_iterator_tag>());
+
+static_assert(testWithoutConcept<std::unordered_map<int, int>::iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_map<int, int>::const_iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+static_assert(testWithoutConcept<std::unordered_map<int, int>::local_iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_map<int, int>::const_local_iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+static_assert(testWithoutConcept<std::unordered_multimap<int, int>::iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_multimap<int, int>::const_iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+static_assert(testWithoutConcept<std::unordered_multimap<int, int>::local_iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_multimap<int, int>::const_local_iterator, std::pair<const int, int>, std::forward_iterator_tag>());
+
+static_assert(testConstWithoutConcept<std::unordered_set<int>::iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_set<int>::const_iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_set<int>::local_iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_set<int>::const_local_iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_multiset<int>::iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_multiset<int>::const_iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_multiset<int>::local_iterator, int, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::unordered_multiset<int>::const_local_iterator, int, std::forward_iterator_tag>());
+
+static_assert(testWithoutConcept<std::reverse_iterator<int*>, int, std::random_access_iterator_tag>());
+static_assert(testIOIterator<std::back_insert_iterator<std::vector<int>>, std::output_iterator_tag>());
+static_assert(testIOIterator<std::front_insert_iterator<std::vector<int>>, std::output_iterator_tag>());
+static_assert(testIOIterator<std::insert_iterator<std::vector<int>>, std::output_iterator_tag>());
+static_assert(testConstWithoutConcept<std::istream_iterator<int, char>, int, std::input_iterator_tag>());
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+static_assert(testWithoutConcept<std::istreambuf_iterator<char>, char, long long, char, char*, std::input_iterator_tag>());
+static_assert(testWithoutConcept<std::move_iterator<int*>, int, std::ptr
diff _t, int&&, int*, std::random_access_iterator_tag>());
+static_assert(testIOIterator<std::ostream_iterator<int, char>, std::output_iterator_tag, std::ptr
diff _t>());
+static_assert(testIOIterator<std::ostreambuf_iterator<int, char>, std::output_iterator_tag, std::ptr
diff _t>());
+static_assert(testConstWithoutConcept<std::cregex_iterator, std::cmatch, std::forward_iterator_tag>());
+static_assert(testConstWithoutConcept<std::cregex_token_iterator, std::csub_match, std::forward_iterator_tag>());
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
-static_assert(testStdlibIterator<std::filesystem::directory_iterator, std::filesystem::directory_entry, std::ptr
diff _t,
+static_assert(testWithoutConcept<std::filesystem::directory_iterator, std::filesystem::directory_entry, std::ptr
diff _t,
const std::filesystem::directory_entry&, const std::filesystem::directory_entry*,
std::input_iterator_tag>());
-static_assert(testStdlibIterator<std::filesystem::recursive_directory_iterator, std::filesystem::directory_entry,
+static_assert(testWithoutConcept<std::filesystem::recursive_directory_iterator, std::filesystem::directory_entry,
std::ptr
diff _t, const std::filesystem::directory_entry&,
const std::filesystem::directory_entry*, std::input_iterator_tag>());
#endif
-static_assert(testBothStdlibIterators<std::forward_list<int>, int, std::forward_iterator_tag>());
-static_assert(testBothStdlibIterators<std::deque<int>, int, std::random_access_iterator_tag>());
-static_assert(testBothStdlibIterators<std::list<int>, int, std::bidirectional_iterator_tag>());
-static_assert(testStdlibIterator<std::set<int>::iterator, int, std::ptr
diff _t, const int&, const int*,
- std::bidirectional_iterator_tag>());
-static_assert(testStdlibIterator<std::set<int>::const_iterator, int, std::ptr
diff _t, const int&, const int*,
- std::bidirectional_iterator_tag>());
-static_assert(
- testBothStdlibIterators<std::map<int, int>, std::pair<const int, int>, std::bidirectional_iterator_tag>());
-static_assert(
- testBothStdlibIterators<std::unordered_map<int, int>, std::pair<const int, int>, std::forward_iterator_tag>());
-static_assert(testStdlibIterator<std::unordered_map<int, int>::local_iterator, std::pair<const int, int>,
- std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_map<int, int>::const_local_iterator, std::pair<const int, int>,
- std::forward_iterator_tag>());
-static_assert(
- testBothStdlibIterators<std::unordered_multimap<int, int>, std::pair<const int, int>, std::forward_iterator_tag>());
-static_assert(testStdlibIterator<std::unordered_multimap<int, int>::local_iterator, std::pair<const int, int>,
- std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_multimap<int, int>::const_local_iterator,
- std::pair<const int, int>, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_set<int>::iterator, int, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_set<int>::const_iterator, int, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_set<int>::local_iterator, int, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_set<int>::const_local_iterator, int, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_multiset<int>::iterator, int, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_multiset<int>::const_iterator, int, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::unordered_multiset<int>::local_iterator, int, std::forward_iterator_tag>());
-static_assert(
- testStdlibIteratorConst<std::unordered_multiset<int>::const_local_iterator, int, std::forward_iterator_tag>());
-
-static_assert(
- testStdlibIterator<std::reverse_iterator<std::vector<int>::iterator>, int, std::random_access_iterator_tag>());
-static_assert(
- testStdlibIterator<std::back_insert_iterator<std::vector<int>::iterator>, void, std::output_iterator_tag>());
-static_assert(
- testStdlibIterator<std::front_insert_iterator<std::vector<int>::iterator>, void, std::output_iterator_tag>());
-static_assert(testStdlibIterator<std::insert_iterator<std::vector<int> >, void, std::output_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::istream_iterator<int, char>, int, std::input_iterator_tag>());
-
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-static_assert(
- testStdlibIterator<std::istreambuf_iterator<char>, char, long long, char, char*, std::input_iterator_tag>());
-using MoveIter = std::move_iterator<std::vector<int>::iterator>;
-static_assert(
- testStdlibIterator<MoveIter, int, std::ptr
diff _t, int&&, MoveIter::pointer, std::random_access_iterator_tag>());
-static_assert(testStdlibIterator<std::ostream_iterator<int, char>, void, std::output_iterator_tag, std::ptr
diff _t>());
-static_assert(
- testStdlibIterator<std::ostreambuf_iterator<int, char>, void, std::output_iterator_tag, std::ptr
diff _t>());
-static_assert(testStdlibIteratorConst<std::cregex_iterator, std::cmatch, std::forward_iterator_tag>());
-static_assert(testStdlibIteratorConst<std::cregex_token_iterator, std::csub_match, std::forward_iterator_tag>());
-#endif // !_LIBCPP_HAS_NO_LOCALIZATION
// Local test iterators.
@@ -202,12 +225,9 @@ struct AllMembers {
struct pointer {};
};
using AllMembersTraits = std::iterator_traits<AllMembers>;
-static_assert(std::same_as<AllMembersTraits::iterator_category,
- AllMembers::iterator_category>);
-static_assert(
- std::same_as<AllMembersTraits::value_type, AllMembers::value_type>);
-static_assert(std::same_as<AllMembersTraits::
diff erence_type,
- AllMembers::
diff erence_type>);
+static_assert(std::same_as<AllMembersTraits::iterator_category, AllMembers::iterator_category>);
+static_assert(std::same_as<AllMembersTraits::value_type, AllMembers::value_type>);
+static_assert(std::same_as<AllMembersTraits::
diff erence_type, AllMembers::
diff erence_type>);
static_assert(std::same_as<AllMembersTraits::reference, AllMembers::reference>);
static_assert(std::same_as<AllMembersTraits::pointer, AllMembers::pointer>);
static_assert(!has_iterator_concept_v<AllMembersTraits>);
@@ -221,45 +241,34 @@ struct NoPointerMember {
value_type* operator->() const;
};
using NoPointerMemberTraits = std::iterator_traits<NoPointerMember>;
-static_assert(std::same_as<NoPointerMemberTraits::iterator_category,
- NoPointerMember::iterator_category>);
-static_assert(std::same_as<NoPointerMemberTraits::value_type,
- NoPointerMember::value_type>);
-static_assert(std::same_as<NoPointerMemberTraits::
diff erence_type,
- NoPointerMember::
diff erence_type>);
-static_assert(
- std::same_as<NoPointerMemberTraits::reference, NoPointerMember::reference>);
+static_assert(std::same_as<NoPointerMemberTraits::iterator_category, NoPointerMember::iterator_category>);
+static_assert(std::same_as<NoPointerMemberTraits::value_type, NoPointerMember::value_type>);
+static_assert(std::same_as<NoPointerMemberTraits::
diff erence_type, NoPointerMember::
diff erence_type>);
+static_assert(std::same_as<NoPointerMemberTraits::reference, NoPointerMember::reference>);
static_assert(std::same_as<NoPointerMemberTraits::pointer, void>);
static_assert(!has_iterator_concept_v<NoPointerMemberTraits>);
struct IterConcept {
struct iterator_category {};
- // "iterator_concept" must be defined in a specialization of "iterator_traits", it
- // should not be a member of the iterator itself, so this is ignored.
- struct iterator_concept {};
struct value_type {};
struct
diff erence_type {};
struct reference {};
struct pointer {};
+ // iterator_traits does NOT pass through the iterator_concept of the type itself.
+ struct iterator_concept {};
};
using IterConceptTraits = std::iterator_traits<IterConcept>;
-static_assert(std::same_as<IterConceptTraits::iterator_category,
- IterConcept::iterator_category>);
-static_assert(
- std::same_as<IterConceptTraits::value_type, IterConcept::value_type>);
-static_assert(std::same_as<IterConceptTraits::
diff erence_type,
- IterConcept::
diff erence_type>);
-static_assert(
- std::same_as<IterConceptTraits::reference, IterConcept::reference>);
+static_assert(std::same_as<IterConceptTraits::iterator_category, IterConcept::iterator_category>);
+static_assert(std::same_as<IterConceptTraits::value_type, IterConcept::value_type>);
+static_assert(std::same_as<IterConceptTraits::
diff erence_type, IterConcept::
diff erence_type>);
+static_assert(std::same_as<IterConceptTraits::reference, IterConcept::reference>);
static_assert(std::same_as<IterConceptTraits::pointer, IterConcept::pointer>);
static_assert(!has_iterator_concept_v<IterConceptTraits>);
struct LegacyInput {
struct iterator_category {};
struct value_type {};
- struct reference {
- operator value_type() const;
- };
+ struct reference { operator value_type() const; };
friend bool operator==(LegacyInput, LegacyInput);
reference operator*() const;
@@ -271,22 +280,17 @@ struct std::incrementable_traits<LegacyInput> {
using
diff erence_type = short;
};
using LegacyInputTraits = std::iterator_traits<LegacyInput>;
-static_assert(std::same_as<LegacyInputTraits::iterator_category,
- LegacyInput::iterator_category>);
-static_assert(
- std::same_as<LegacyInputTraits::value_type, LegacyInput::value_type>);
+static_assert(std::same_as<LegacyInputTraits::iterator_category, LegacyInput::iterator_category>);
+static_assert(std::same_as<LegacyInputTraits::value_type, LegacyInput::value_type>);
static_assert(std::same_as<LegacyInputTraits::
diff erence_type, short>);
-static_assert(
- std::same_as<LegacyInputTraits::reference, LegacyInput::reference>);
+static_assert(std::same_as<LegacyInputTraits::reference, LegacyInput::reference>);
static_assert(std::same_as<LegacyInputTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyInputTraits>);
struct LegacyInputNoValueType {
struct not_value_type {};
using
diff erence_type = int; // or any signed integral type
- struct reference {
- operator not_value_type() const;
- };
+ struct reference { operator not_value_type&() const; };
friend bool operator==(LegacyInputNoValueType, LegacyInputNoValueType);
reference operator*() const;
@@ -297,15 +301,11 @@ template <>
struct std::indirectly_readable_traits<LegacyInputNoValueType> {
using value_type = LegacyInputNoValueType::not_value_type;
};
-using LegacyInputNoValueTypeTraits =
- std::iterator_traits<LegacyInputNoValueType>;
-static_assert(std::same_as<LegacyInputNoValueTypeTraits::iterator_category,
- std::input_iterator_tag>);
-static_assert(std::same_as<LegacyInputNoValueTypeTraits::value_type,
- LegacyInputNoValueType::not_value_type>);
+using LegacyInputNoValueTypeTraits = std::iterator_traits<LegacyInputNoValueType>;
+static_assert(std::same_as<LegacyInputNoValueTypeTraits::iterator_category, std::input_iterator_tag>);
+static_assert(std::same_as<LegacyInputNoValueTypeTraits::value_type, LegacyInputNoValueType::not_value_type>);
static_assert(std::same_as<LegacyInputNoValueTypeTraits::
diff erence_type, int>);
-static_assert(std::same_as<LegacyInputNoValueTypeTraits::reference,
- LegacyInputNoValueType::reference>);
+static_assert(std::same_as<LegacyInputNoValueTypeTraits::reference, LegacyInputNoValueType::reference>);
static_assert(std::same_as<LegacyInputNoValueTypeTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyInputNoValueTypeTraits>);
@@ -326,13 +326,10 @@ struct std::incrementable_traits<LegacyForward> {
using
diff erence_type = short; // or any signed integral type
};
using LegacyForwardTraits = std::iterator_traits<LegacyForward>;
-static_assert(std::same_as<LegacyForwardTraits::iterator_category,
- std::forward_iterator_tag>);
-static_assert(std::same_as<LegacyForwardTraits::value_type,
- LegacyForward::not_value_type>);
+static_assert(std::same_as<LegacyForwardTraits::iterator_category, std::forward_iterator_tag>);
+static_assert(std::same_as<LegacyForwardTraits::value_type, LegacyForward::not_value_type>);
static_assert(std::same_as<LegacyForwardTraits::
diff erence_type, short>);
-static_assert(std::same_as<LegacyForwardTraits::reference,
- const LegacyForward::not_value_type&>);
+static_assert(std::same_as<LegacyForwardTraits::reference, const LegacyForward::not_value_type&>);
static_assert(std::same_as<LegacyForwardTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyForwardTraits>);
@@ -348,13 +345,10 @@ struct LegacyBidirectional {
friend short operator-(LegacyBidirectional, LegacyBidirectional);
};
using LegacyBidirectionalTraits = std::iterator_traits<LegacyBidirectional>;
-static_assert(std::same_as<LegacyBidirectionalTraits::iterator_category,
- std::bidirectional_iterator_tag>);
-static_assert(std::same_as<LegacyBidirectionalTraits::value_type,
- LegacyBidirectional::value_type>);
+static_assert(std::same_as<LegacyBidirectionalTraits::iterator_category, std::bidirectional_iterator_tag>);
+static_assert(std::same_as<LegacyBidirectionalTraits::value_type, LegacyBidirectional::value_type>);
static_assert(std::same_as<LegacyBidirectionalTraits::
diff erence_type, short>);
-static_assert(std::same_as<LegacyBidirectionalTraits::reference,
- const LegacyBidirectional::value_type&>);
+static_assert(std::same_as<LegacyBidirectionalTraits::reference, const LegacyBidirectional::value_type&>);
static_assert(std::same_as<LegacyBidirectionalTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyBidirectionalTraits>);
@@ -382,21 +376,18 @@ struct std::incrementable_traits<MinusNotDeclaredIter> {
using
diff erence_type = short;
};
using MinusNotDeclaredIterTraits = std::iterator_traits<MinusNotDeclaredIter>;
-static_assert(std::same_as<MinusNotDeclaredIterTraits::iterator_category,
- std::bidirectional_iterator_tag>);
-static_assert(std::same_as<MinusNotDeclaredIterTraits::value_type,
- MinusNotDeclaredIter::value_type>);
+static_assert(std::same_as<MinusNotDeclaredIterTraits::iterator_category, std::bidirectional_iterator_tag>);
+static_assert(std::same_as<MinusNotDeclaredIterTraits::value_type, MinusNotDeclaredIter::value_type>);
static_assert(std::same_as<MinusNotDeclaredIterTraits::
diff erence_type, short>);
-static_assert(std::same_as<MinusNotDeclaredIterTraits::reference,
- const MinusNotDeclaredIter::value_type&>);
+static_assert(std::same_as<MinusNotDeclaredIterTraits::reference, const MinusNotDeclaredIter::value_type&>);
static_assert(std::same_as<MinusNotDeclaredIterTraits::pointer, void>);
static_assert(!has_iterator_concept_v<MinusNotDeclaredIterTraits>);
struct WrongSubscriptReturnType {
struct value_type {};
- friend auto operator<=>(WrongSubscriptReturnType,
- WrongSubscriptReturnType) = default;
+ friend auto operator<=>(WrongSubscriptReturnType, WrongSubscriptReturnType) = default;
+
// The type of it[n] is not convertible to the type of *it; therefore, this is not random-access.
value_type& operator*() const;
const value_type& operator[](long) const;
@@ -411,16 +402,11 @@ struct WrongSubscriptReturnType {
friend WrongSubscriptReturnType operator+(WrongSubscriptReturnType, int);
friend WrongSubscriptReturnType operator+(int, WrongSubscriptReturnType);
};
-using WrongSubscriptReturnTypeTraits =
- std::iterator_traits<WrongSubscriptReturnType>;
-static_assert(std::same_as<WrongSubscriptReturnTypeTraits::iterator_category,
- std::bidirectional_iterator_tag>);
-static_assert(std::same_as<WrongSubscriptReturnTypeTraits::value_type,
- WrongSubscriptReturnType::value_type>);
-static_assert(
- std::same_as<WrongSubscriptReturnTypeTraits::
diff erence_type, short>);
-static_assert(std::same_as<WrongSubscriptReturnTypeTraits::reference,
- WrongSubscriptReturnType::value_type&>);
+using WrongSubscriptReturnTypeTraits = std::iterator_traits<WrongSubscriptReturnType>;
+static_assert(std::same_as<WrongSubscriptReturnTypeTraits::iterator_category, std::bidirectional_iterator_tag>);
+static_assert(std::same_as<WrongSubscriptReturnTypeTraits::value_type, WrongSubscriptReturnType::value_type>);
+static_assert(std::same_as<WrongSubscriptReturnTypeTraits::
diff erence_type, short>);
+static_assert(std::same_as<WrongSubscriptReturnTypeTraits::reference, WrongSubscriptReturnType::value_type&>);
static_assert(std::same_as<WrongSubscriptReturnTypeTraits::pointer, void>);
static_assert(!has_iterator_concept_v<WrongSubscriptReturnTypeTraits>);
@@ -446,24 +432,18 @@ struct LegacyRandomAccess {
friend LegacyRandomAccess operator+(int, LegacyRandomAccess);
};
using LegacyRandomAccessTraits = std::iterator_traits<LegacyRandomAccess>;
-static_assert(std::same_as<LegacyRandomAccessTraits::iterator_category,
- std::random_access_iterator_tag>);
-static_assert(std::same_as<LegacyRandomAccessTraits::value_type,
- LegacyRandomAccess::value_type>);
+static_assert(std::same_as<LegacyRandomAccessTraits::iterator_category, std::random_access_iterator_tag>);
+static_assert(std::same_as<LegacyRandomAccessTraits::value_type, LegacyRandomAccess::value_type>);
static_assert(std::same_as<LegacyRandomAccessTraits::
diff erence_type, short>);
-static_assert(std::same_as<LegacyRandomAccessTraits::reference,
- const LegacyRandomAccess::value_type&>);
+static_assert(std::same_as<LegacyRandomAccessTraits::reference, const LegacyRandomAccess::value_type&>);
static_assert(std::same_as<LegacyRandomAccessTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyRandomAccessTraits>);
struct LegacyRandomAccessSpaceship {
struct not_value_type {};
- struct ReferenceConvertible {
- operator not_value_type&() const;
- };
+ struct ReferenceConvertible { operator not_value_type&() const; };
- friend auto operator<=>(LegacyRandomAccessSpaceship,
- LegacyRandomAccessSpaceship) = default;
+ friend auto operator<=>(LegacyRandomAccessSpaceship, LegacyRandomAccessSpaceship) = default;
not_value_type& operator*() const;
ReferenceConvertible operator[](long) const;
LegacyRandomAccessSpaceship& operator++();
@@ -472,14 +452,10 @@ struct LegacyRandomAccessSpaceship {
LegacyRandomAccessSpaceship operator--(int);
LegacyRandomAccessSpaceship& operator+=(long);
LegacyRandomAccessSpaceship& operator-=(long);
- friend short operator-(LegacyRandomAccessSpaceship,
- LegacyRandomAccessSpaceship);
- friend LegacyRandomAccessSpaceship operator-(LegacyRandomAccessSpaceship,
- int);
- friend LegacyRandomAccessSpaceship operator+(LegacyRandomAccessSpaceship,
- int);
- friend LegacyRandomAccessSpaceship operator+(int,
- LegacyRandomAccessSpaceship);
+ friend short operator-(LegacyRandomAccessSpaceship, LegacyRandomAccessSpaceship);
+ friend LegacyRandomAccessSpaceship operator-(LegacyRandomAccessSpaceship, int);
+ friend LegacyRandomAccessSpaceship operator+(LegacyRandomAccessSpaceship, int);
+ friend LegacyRandomAccessSpaceship operator+(int, LegacyRandomAccessSpaceship);
};
template <>
struct std::indirectly_readable_traits<LegacyRandomAccessSpaceship> {
@@ -489,16 +465,11 @@ template <>
struct std::incrementable_traits<LegacyRandomAccessSpaceship> {
using
diff erence_type = short; // or any signed integral type
};
-using LegacyRandomAccessSpaceshipTraits =
- std::iterator_traits<LegacyRandomAccessSpaceship>;
-static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::iterator_category,
- std::random_access_iterator_tag>);
-static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::value_type,
- LegacyRandomAccessSpaceship::not_value_type>);
-static_assert(
- std::same_as<LegacyRandomAccessSpaceshipTraits::
diff erence_type, short>);
-static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::reference,
- LegacyRandomAccessSpaceship::not_value_type&>);
+using LegacyRandomAccessSpaceshipTraits = std::iterator_traits<LegacyRandomAccessSpaceship>;
+static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::iterator_category, std::random_access_iterator_tag>);
+static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::value_type, LegacyRandomAccessSpaceship::not_value_type>);
+static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::
diff erence_type, short>);
+static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::reference, LegacyRandomAccessSpaceship::not_value_type&>);
static_assert(std::same_as<LegacyRandomAccessSpaceshipTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyRandomAccessSpaceshipTraits>);
@@ -510,8 +481,7 @@ struct BareLegacyOutput {
BareLegacyOutput operator++(int);
};
using BareLegacyOutputTraits = std::iterator_traits<BareLegacyOutput>;
-static_assert(std::same_as<BareLegacyOutputTraits::iterator_category,
- std::output_iterator_tag>);
+static_assert(std::same_as<BareLegacyOutputTraits::iterator_category, std::output_iterator_tag>);
static_assert(std::same_as<BareLegacyOutputTraits::value_type, void>);
static_assert(std::same_as<BareLegacyOutputTraits::
diff erence_type, void>);
static_assert(std::same_as<BareLegacyOutputTraits::reference, void>);
@@ -528,11 +498,9 @@ struct LegacyOutputWithMinus {
// Lacking operator==, this is a LegacyIterator but not a LegacyInputIterator.
};
using LegacyOutputWithMinusTraits = std::iterator_traits<LegacyOutputWithMinus>;
-static_assert(std::same_as<LegacyOutputWithMinusTraits::iterator_category,
- std::output_iterator_tag>);
+static_assert(std::same_as<LegacyOutputWithMinusTraits::iterator_category, std::output_iterator_tag>);
static_assert(std::same_as<LegacyOutputWithMinusTraits::value_type, void>);
-static_assert(
- std::same_as<LegacyOutputWithMinusTraits::
diff erence_type, short>);
+static_assert(std::same_as<LegacyOutputWithMinusTraits::
diff erence_type, short>);
static_assert(std::same_as<LegacyOutputWithMinusTraits::reference, void>);
static_assert(std::same_as<LegacyOutputWithMinusTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyOutputWithMinusTraits>);
@@ -542,23 +510,17 @@ struct LegacyOutputWithMemberTypes {
struct reference {}; // ignored
using
diff erence_type = long;
- friend bool operator==(LegacyOutputWithMemberTypes,
- LegacyOutputWithMemberTypes);
+ friend bool operator==(LegacyOutputWithMemberTypes, LegacyOutputWithMemberTypes);
reference operator*() const;
LegacyOutputWithMemberTypes& operator++();
LegacyOutputWithMemberTypes operator++(int);
- friend short operator-(LegacyOutputWithMemberTypes,
- LegacyOutputWithMemberTypes); // ignored
+ friend short operator-(LegacyOutputWithMemberTypes, LegacyOutputWithMemberTypes); // ignored
// Since (*it) is not convertible to value_type, this is not a LegacyInputIterator.
};
-using LegacyOutputWithMemberTypesTraits =
- std::iterator_traits<LegacyOutputWithMemberTypes>;
-static_assert(std::same_as<LegacyOutputWithMemberTypesTraits::iterator_category,
- std::output_iterator_tag>);
-static_assert(
- std::same_as<LegacyOutputWithMemberTypesTraits::value_type, void>);
-static_assert(
- std::same_as<LegacyOutputWithMemberTypesTraits::
diff erence_type, long>);
+using LegacyOutputWithMemberTypesTraits = std::iterator_traits<LegacyOutputWithMemberTypes>;
+static_assert(std::same_as<LegacyOutputWithMemberTypesTraits::iterator_category, std::output_iterator_tag>);
+static_assert(std::same_as<LegacyOutputWithMemberTypesTraits::value_type, void>);
+static_assert(std::same_as<LegacyOutputWithMemberTypesTraits::
diff erence_type, long>);
static_assert(std::same_as<LegacyOutputWithMemberTypesTraits::reference, void>);
static_assert(std::same_as<LegacyOutputWithMemberTypesTraits::pointer, void>);
static_assert(!has_iterator_concept_v<LegacyOutputWithMemberTypesTraits>);
@@ -566,8 +528,7 @@ static_assert(!has_iterator_concept_v<LegacyOutputWithMemberTypesTraits>);
struct LegacyRandomAccessSpecialized {
struct not_value_type {};
- friend auto operator<=>(LegacyRandomAccessSpecialized,
- LegacyRandomAccessSpecialized) = default;
+ friend auto operator<=>(LegacyRandomAccessSpecialized, LegacyRandomAccessSpecialized) = default;
not_value_type& operator*() const;
not_value_type& operator[](long) const;
LegacyRandomAccessSpecialized& operator++();
@@ -576,97 +537,75 @@ struct LegacyRandomAccessSpecialized {
LegacyRandomAccessSpecialized operator--(int);
LegacyRandomAccessSpecialized& operator+=(long);
LegacyRandomAccessSpecialized& operator-=(long);
- friend long operator-(LegacyRandomAccessSpecialized,
- LegacyRandomAccessSpecialized);
- friend LegacyRandomAccessSpecialized operator-(LegacyRandomAccessSpecialized,
- int);
- friend LegacyRandomAccessSpecialized operator+(LegacyRandomAccessSpecialized,
- int);
- friend LegacyRandomAccessSpecialized operator+(int,
- LegacyRandomAccessSpecialized);
+ friend long operator-(LegacyRandomAccessSpecialized, LegacyRandomAccessSpecialized);
+ friend LegacyRandomAccessSpecialized operator-(LegacyRandomAccessSpecialized, int);
+ friend LegacyRandomAccessSpecialized operator+(LegacyRandomAccessSpecialized, int);
+ friend LegacyRandomAccessSpecialized operator+(int, LegacyRandomAccessSpecialized);
};
template <class I>
-requires std::same_as<
- I, LegacyRandomAccessSpecialized> struct std::iterator_traits<I> {
+ requires std::same_as<I, LegacyRandomAccessSpecialized>
+struct std::iterator_traits<I>
+{
using iterator_category = std::output_iterator_tag;
using value_type = short;
using
diff erence_type = short;
using reference = short&;
using pointer = short*;
};
-using LegacyRandomAccessSpecializedTraits =
- std::iterator_traits<LegacyRandomAccessSpecialized>;
-static_assert(
- std::same_as<LegacyRandomAccessSpecializedTraits::iterator_category,
- std::output_iterator_tag>);
-static_assert(
- std::same_as<LegacyRandomAccessSpecializedTraits::value_type, short>);
-static_assert(
- std::same_as<LegacyRandomAccessSpecializedTraits::
diff erence_type, short>);
-static_assert(
- std::same_as<LegacyRandomAccessSpecializedTraits::reference, short&>);
-static_assert(
- std::same_as<LegacyRandomAccessSpecializedTraits::pointer, short*>);
+using LegacyRandomAccessSpecializedTraits = std::iterator_traits<LegacyRandomAccessSpecialized>;
+static_assert(std::same_as<LegacyRandomAccessSpecializedTraits::iterator_category, std::output_iterator_tag>);
+static_assert(std::same_as<LegacyRandomAccessSpecializedTraits::value_type, short>);
+static_assert(std::same_as<LegacyRandomAccessSpecializedTraits::
diff erence_type, short>);
+static_assert(std::same_as<LegacyRandomAccessSpecializedTraits::reference, short&>);
+static_assert(std::same_as<LegacyRandomAccessSpecializedTraits::pointer, short*>);
static_assert(!has_iterator_concept_v<LegacyRandomAccessSpecializedTraits>);
// Other test iterators.
-using InputTestItereatorTraits = std::iterator_traits<cpp17_input_iterator<int*> >;
-static_assert(std::same_as<InputTestItereatorTraits::iterator_category,
- std::input_iterator_tag>);
-static_assert(std::same_as<InputTestItereatorTraits::value_type, int>);
-static_assert(std::same_as<InputTestItereatorTraits::
diff erence_type, std::ptr
diff _t>);
-static_assert(std::same_as<InputTestItereatorTraits::reference, int&>);
-static_assert(std::same_as<InputTestItereatorTraits::pointer, int*>);
-static_assert(!has_iterator_concept_v<InputTestItereatorTraits>);
-
-using OutputTestItereatorTraits = std::iterator_traits<output_iterator<int*> >;
-static_assert(std::same_as<OutputTestItereatorTraits::iterator_category,
- std::output_iterator_tag>);
-static_assert(std::same_as<OutputTestItereatorTraits::value_type, void>);
-static_assert(std::same_as<OutputTestItereatorTraits::
diff erence_type, std::ptr
diff _t>);
-static_assert(std::same_as<OutputTestItereatorTraits::reference, int&>);
-static_assert(std::same_as<OutputTestItereatorTraits::pointer, int*>);
-static_assert(!has_iterator_concept_v<OutputTestItereatorTraits>);
-
-using ForwardTestIteratorTraits = std::iterator_traits<forward_iterator<int*> >;
-static_assert(std::same_as<ForwardTestIteratorTraits::iterator_category,
- std::forward_iterator_tag>);
+using InputTestIteratorTraits = std::iterator_traits<cpp17_input_iterator<int*>>;
+static_assert(std::same_as<InputTestIteratorTraits::iterator_category, std::input_iterator_tag>);
+static_assert(std::same_as<InputTestIteratorTraits::value_type, int>);
+static_assert(std::same_as<InputTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
+static_assert(std::same_as<InputTestIteratorTraits::reference, int&>);
+static_assert(std::same_as<InputTestIteratorTraits::pointer, int*>);
+static_assert(!has_iterator_concept_v<InputTestIteratorTraits>);
+
+using OutputTestIteratorTraits = std::iterator_traits<output_iterator<int*>>;
+static_assert(std::same_as<OutputTestIteratorTraits::iterator_category, std::output_iterator_tag>);
+static_assert(std::same_as<OutputTestIteratorTraits::value_type, void>);
+static_assert(std::same_as<OutputTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
+static_assert(std::same_as<OutputTestIteratorTraits::reference, int&>);
+static_assert(std::same_as<OutputTestIteratorTraits::pointer, int*>);
+static_assert(!has_iterator_concept_v<OutputTestIteratorTraits>);
+
+using ForwardTestIteratorTraits = std::iterator_traits<forward_iterator<int*>>;
+static_assert(std::same_as<ForwardTestIteratorTraits::iterator_category, std::forward_iterator_tag>);
static_assert(std::same_as<ForwardTestIteratorTraits::value_type, int>);
static_assert(std::same_as<ForwardTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
static_assert(std::same_as<ForwardTestIteratorTraits::reference, int&>);
static_assert(std::same_as<ForwardTestIteratorTraits::pointer, int*>);
static_assert(!has_iterator_concept_v<ForwardTestIteratorTraits>);
-using BidirectionalTestIteratorTraits =
- std::iterator_traits<bidirectional_iterator<int*> >;
-static_assert(std::same_as<BidirectionalTestIteratorTraits::iterator_category,
- std::bidirectional_iterator_tag>);
+using BidirectionalTestIteratorTraits = std::iterator_traits<bidirectional_iterator<int*>>;
+static_assert(std::same_as<BidirectionalTestIteratorTraits::iterator_category, std::bidirectional_iterator_tag>);
static_assert(std::same_as<BidirectionalTestIteratorTraits::value_type, int>);
-static_assert(
- std::same_as<BidirectionalTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
+static_assert(std::same_as<BidirectionalTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
static_assert(std::same_as<BidirectionalTestIteratorTraits::reference, int&>);
static_assert(std::same_as<BidirectionalTestIteratorTraits::pointer, int*>);
static_assert(!has_iterator_concept_v<BidirectionalTestIteratorTraits>);
-using RandomAccessTestIteratorTraits =
- std::iterator_traits<random_access_iterator<int*> >;
-static_assert(std::same_as<RandomAccessTestIteratorTraits::iterator_category,
- std::random_access_iterator_tag>);
+using RandomAccessTestIteratorTraits = std::iterator_traits<random_access_iterator<int*>>;
+static_assert(std::same_as<RandomAccessTestIteratorTraits::iterator_category, std::random_access_iterator_tag>);
static_assert(std::same_as<RandomAccessTestIteratorTraits::value_type, int>);
-static_assert(
- std::same_as<RandomAccessTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
+static_assert(std::same_as<RandomAccessTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
static_assert(std::same_as<RandomAccessTestIteratorTraits::reference, int&>);
static_assert(std::same_as<RandomAccessTestIteratorTraits::pointer, int*>);
static_assert(!has_iterator_concept_v<RandomAccessTestIteratorTraits>);
-using ContiguousTestIteratorTraits =
- std::iterator_traits<contiguous_iterator<int*> >;
-static_assert(std::same_as<ContiguousTestIteratorTraits::iterator_category,
- std::contiguous_iterator_tag>);
+using ContiguousTestIteratorTraits = std::iterator_traits<contiguous_iterator<int*>>;
+static_assert(std::same_as<ContiguousTestIteratorTraits::iterator_category, std::contiguous_iterator_tag>);
static_assert(std::same_as<ContiguousTestIteratorTraits::value_type, int>);
-static_assert(
- std::same_as<ContiguousTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
+static_assert(std::same_as<ContiguousTestIteratorTraits::
diff erence_type, std::ptr
diff _t>);
static_assert(std::same_as<ContiguousTestIteratorTraits::reference, int&>);
static_assert(std::same_as<ContiguousTestIteratorTraits::pointer, int*>);
static_assert(!has_iterator_concept_v<ContiguousTestIteratorTraits>);
diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/incrementable_traits.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/incrementable_traits.compile.pass.cpp
index 7316991a4987..eaf7d65691d1 100644
--- a/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/incrementable_traits.compile.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/incrementable_traits.compile.pass.cpp
@@ -19,7 +19,6 @@
#include "test_macros.h"
-// clang-format off
template <class T>
concept check_has_
diff erence_type = requires {
typename std::incrementable_traits<T>::
diff erence_type;
@@ -29,10 +28,9 @@ template <class T, class Expected>
concept check_
diff erence_type_matches =
check_has_
diff erence_type<T> &&
std::same_as<typename std::incrementable_traits<T>::
diff erence_type, Expected>;
-// clang-format on
template <class T, class Expected>
-[[nodiscard]] constexpr bool check_incrementable_traits() noexcept {
+constexpr bool check_incrementable_traits() {
constexpr bool result = check_
diff erence_type_matches<T, Expected>;
static_assert(check_
diff erence_type_matches<T const, Expected> == result);
return result;
@@ -41,8 +39,7 @@ template <class T, class Expected>
static_assert(check_incrementable_traits<float*, std::ptr
diff _t>());
static_assert(check_incrementable_traits<float const*, std::ptr
diff _t>());
static_assert(check_incrementable_traits<float volatile*, std::ptr
diff _t>());
-static_assert(
- check_incrementable_traits<float const volatile*, std::ptr
diff _t>());
+static_assert(check_incrementable_traits<float const volatile*, std::ptr
diff _t>());
static_assert(check_incrementable_traits<float**, std::ptr
diff _t>());
static_assert(check_incrementable_traits<int[], std::ptr
diff _t>());
@@ -83,42 +80,31 @@ struct non_integral_
diff erence_type {
static_assert(check_incrementable_traits<non_integral_
diff erence_type, void>());
struct int_subtraction {
- friend int operator-(int_subtraction, int_subtraction) noexcept;
+ friend int operator-(int_subtraction, int_subtraction);
};
static_assert(check_incrementable_traits<int_subtraction, int>());
static_assert(!check_incrementable_traits<int_subtraction volatile&, int>());
-static_assert(
- !check_incrementable_traits<int_subtraction const volatile&, int>());
+static_assert(!check_incrementable_traits<int_subtraction const volatile&, int>());
struct char_subtraction {
- friend char operator-(char_subtraction, char_subtraction) noexcept;
+ friend char operator-(char_subtraction, char_subtraction);
};
static_assert(check_incrementable_traits<char_subtraction, signed char>());
struct unsigned_int_subtraction_with_cv {
- friend unsigned int
- operator-(unsigned_int_subtraction_with_cv const&,
- unsigned_int_subtraction_with_cv const&) noexcept;
- friend unsigned int
- operator-(unsigned_int_subtraction_with_cv const volatile&,
- unsigned_int_subtraction_with_cv const volatile&) noexcept;
+ friend unsigned int operator-(unsigned_int_subtraction_with_cv const&, unsigned_int_subtraction_with_cv const&);
+ friend unsigned int operator-(unsigned_int_subtraction_with_cv const volatile&, unsigned_int_subtraction_with_cv const volatile&);
};
-static_assert(
- check_incrementable_traits<unsigned_int_subtraction_with_cv, int>());
-static_assert(check_incrementable_traits<
- unsigned_int_subtraction_with_cv volatile&, int>());
-static_assert(check_incrementable_traits<
- unsigned_int_subtraction_with_cv const volatile&, int>());
+static_assert(check_incrementable_traits<unsigned_int_subtraction_with_cv, int>());
+static_assert(check_incrementable_traits<unsigned_int_subtraction_with_cv volatile&, int>());
+static_assert(check_incrementable_traits<unsigned_int_subtraction_with_cv const volatile&, int>());
struct specialised_incrementable_traits {};
-namespace std {
template <>
-struct incrementable_traits<specialised_incrementable_traits> {
+struct std::incrementable_traits<specialised_incrementable_traits> {
using
diff erence_type = int;
};
-} // namespace std
-static_assert(
- check_incrementable_traits<specialised_incrementable_traits, int>());
+static_assert(check_incrementable_traits<specialised_incrementable_traits, int>());
static_assert(!check_has_
diff erence_type<void>);
static_assert(!check_has_
diff erence_type<float>);
@@ -136,17 +122,13 @@ static_assert(!check_has_
diff erence_type<int (*)() noexcept>);
static_assert(!check_has_
diff erence_type<int (&)()>);
static_assert(!check_has_
diff erence_type<int (&)() noexcept>);
-#define TEST_POINTER_TO_MEMBER_FUNCTION(type, cv_qualifier) \
- static_assert(!check_has_
diff erence_type<int (type::*)() cv_qualifier>); \
- static_assert( \
- !check_has_
diff erence_type<int (type::*)() cv_qualifier noexcept>); \
- static_assert(!check_has_
diff erence_type<int (type::*)() cv_qualifier&>); \
- static_assert( \
- !check_has_
diff erence_type<int (type::*)() cv_qualifier & noexcept>); \
- static_assert(!check_has_
diff erence_type<int (type::*)() cv_qualifier&&>); \
- static_assert(!check_has_
diff erence_type < int (type::*)() \
- cv_qualifier&& noexcept >); \
- /**/
+#define TEST_POINTER_TO_MEMBER_FUNCTION(type, cv) \
+ static_assert(!check_has_
diff erence_type<int (type::*)() cv>); \
+ static_assert(!check_has_
diff erence_type<int (type::*)() cv noexcept>); \
+ static_assert(!check_has_
diff erence_type<int (type::*)() cv&>); \
+ static_assert(!check_has_
diff erence_type<int (type::*)() cv& noexcept>); \
+ static_assert(!check_has_
diff erence_type<int (type::*)() cv&&>); \
+ static_assert(!check_has_
diff erence_type<int (type::*)() cv&& noexcept>);
struct empty {};
@@ -157,104 +139,102 @@ TEST_POINTER_TO_MEMBER_FUNCTION(empty, volatile);
TEST_POINTER_TO_MEMBER_FUNCTION(empty, const volatile);
struct void_subtraction {
- friend void operator-(void_subtraction, void_subtraction) noexcept;
+ friend void operator-(void_subtraction, void_subtraction);
};
static_assert(!check_has_
diff erence_type<void_subtraction>);
-#define TEST_NOT_DIFFERENCE_TYPE(qual1, qual2) \
- struct TEST_CONCAT(test_subtraction_, __LINE__) { \
- friend int operator-(TEST_CONCAT(test_subtraction_, __LINE__) qual1, \
- TEST_CONCAT(test_subtraction_, __LINE__) qual2); \
- }; \
- static_assert(!check_has_
diff erence_type<TEST_CONCAT(test_subtraction_, \
- __LINE__)>) /**/
-
-TEST_NOT_DIFFERENCE_TYPE(&, &);
-TEST_NOT_DIFFERENCE_TYPE(&, const&);
-TEST_NOT_DIFFERENCE_TYPE(&, volatile&);
-TEST_NOT_DIFFERENCE_TYPE(&, const volatile&);
-TEST_NOT_DIFFERENCE_TYPE(&, &&);
-TEST_NOT_DIFFERENCE_TYPE(&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(const&, &);
-// TEST_NOT_DIFFERENCE_TYPE(const&, const&); // == true
-TEST_NOT_DIFFERENCE_TYPE(const&, volatile&);
-// TEST_NOT_DIFFERENCE_TYPE(const&, const volatile&); // invalid
-TEST_NOT_DIFFERENCE_TYPE(const&, &&);
-TEST_NOT_DIFFERENCE_TYPE(const&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(const&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(const&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(volatile&, &);
-TEST_NOT_DIFFERENCE_TYPE(volatile&, const&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&, volatile&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&, const volatile&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&, &&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(const volatile&, &);
-// TEST_NOT_DIFFERENCE_TYPE(const volatile&, const&); // invalid
-TEST_NOT_DIFFERENCE_TYPE(const volatile&, volatile&);
-// TEST_NOT_DIFFERENCE_TYPE(const volatile&, const volatile&); // invalid
-TEST_NOT_DIFFERENCE_TYPE(const volatile&, &&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(&&, &);
-TEST_NOT_DIFFERENCE_TYPE(&&, const&);
-TEST_NOT_DIFFERENCE_TYPE(&&, volatile&);
-TEST_NOT_DIFFERENCE_TYPE(&&, const volatile&);
-TEST_NOT_DIFFERENCE_TYPE(&&, &&);
-TEST_NOT_DIFFERENCE_TYPE(&&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(&&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(&&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(const&&, &);
-TEST_NOT_DIFFERENCE_TYPE(const&&, const&);
-TEST_NOT_DIFFERENCE_TYPE(const&&, volatile&);
-TEST_NOT_DIFFERENCE_TYPE(const&&, const volatile&);
-TEST_NOT_DIFFERENCE_TYPE(const&&, &&);
-TEST_NOT_DIFFERENCE_TYPE(const&&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(const&&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(const&&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, &);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, const&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, volatile&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, const volatile&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, &&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, &);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, const&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, volatile&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, const volatile&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, &&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, const&&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, const volatile&&);
-
-TEST_NOT_DIFFERENCE_TYPE(&, NO_QUALIFIER);
-// TEST_NOT_DIFFERENCE_TYPE(const&, NO_QUALIFIER); // == true
-TEST_NOT_DIFFERENCE_TYPE(volatile&, NO_QUALIFIER);
-// TEST_NOT_DIFFERENCE_TYPE(const volatile&, NO_QUALIFIER); // invalid
-TEST_NOT_DIFFERENCE_TYPE(&&, NO_QUALIFIER);
-TEST_NOT_DIFFERENCE_TYPE(const&&, NO_QUALIFIER);
-TEST_NOT_DIFFERENCE_TYPE(volatile&&, NO_QUALIFIER);
-TEST_NOT_DIFFERENCE_TYPE(const volatile&&, NO_QUALIFIER);
-
-TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, &);
-// TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, const&); // == true
-TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, volatile&);
-// TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, const volatile&); // invalid
-TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, &&);
-TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, const&&);
-TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, volatile&&);
-TEST_NOT_DIFFERENCE_TYPE(NO_QUALIFIER, const volatile&&);
+#define TEST_NOT_DIFFERENCE_TYPE(S, qual1, qual2) \
+ struct S { \
+ friend int operator-(S qual1, S qual2); \
+ }; \
+ static_assert(!check_has_
diff erence_type<S>)
+
+TEST_NOT_DIFFERENCE_TYPE(A01, &, &);
+TEST_NOT_DIFFERENCE_TYPE(A02, &, const&);
+TEST_NOT_DIFFERENCE_TYPE(A03, &, volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A04, &, const volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A05, &, &&);
+TEST_NOT_DIFFERENCE_TYPE(A06, &, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A07, &, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A08, &, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A11, const&, &);
+// TEST_NOT_DIFFERENCE_TYPE(A12, const&, const&); // == true
+TEST_NOT_DIFFERENCE_TYPE(A13, const&, volatile&);
+// TEST_NOT_DIFFERENCE_TYPE(A14, const&, const volatile&); // invalid
+TEST_NOT_DIFFERENCE_TYPE(A15, const&, &&);
+TEST_NOT_DIFFERENCE_TYPE(A16, const&, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A17, const&, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A18, const&, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A21, volatile&, &);
+TEST_NOT_DIFFERENCE_TYPE(A22, volatile&, const&);
+TEST_NOT_DIFFERENCE_TYPE(A23, volatile&, volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A24, volatile&, const volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A25, volatile&, &&);
+TEST_NOT_DIFFERENCE_TYPE(A26, volatile&, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A27, volatile&, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A28, volatile&, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A31, const volatile&, &);
+// TEST_NOT_DIFFERENCE_TYPE(A32, const volatile&, const&); // invalid
+TEST_NOT_DIFFERENCE_TYPE(A33, const volatile&, volatile&);
+// TEST_NOT_DIFFERENCE_TYPE(A34, const volatile&, const volatile&); // invalid
+TEST_NOT_DIFFERENCE_TYPE(A35, const volatile&, &&);
+TEST_NOT_DIFFERENCE_TYPE(A36, const volatile&, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A37, const volatile&, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A38, const volatile&, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A41, &&, &);
+TEST_NOT_DIFFERENCE_TYPE(A42, &&, const&);
+TEST_NOT_DIFFERENCE_TYPE(A43, &&, volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A44, &&, const volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A45, &&, &&);
+TEST_NOT_DIFFERENCE_TYPE(A46, &&, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A47, &&, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A48, &&, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A51, const&&, &);
+TEST_NOT_DIFFERENCE_TYPE(A52, const&&, const&);
+TEST_NOT_DIFFERENCE_TYPE(A53, const&&, volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A54, const&&, const volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A55, const&&, &&);
+TEST_NOT_DIFFERENCE_TYPE(A56, const&&, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A57, const&&, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A58, const&&, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A61, volatile&&, &);
+TEST_NOT_DIFFERENCE_TYPE(A62, volatile&&, const&);
+TEST_NOT_DIFFERENCE_TYPE(A63, volatile&&, volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A64, volatile&&, const volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A65, volatile&&, &&);
+TEST_NOT_DIFFERENCE_TYPE(A66, volatile&&, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A67, volatile&&, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A68, volatile&&, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A71, const volatile&&, &);
+TEST_NOT_DIFFERENCE_TYPE(A72, const volatile&&, const&);
+TEST_NOT_DIFFERENCE_TYPE(A73, const volatile&&, volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A74, const volatile&&, const volatile&);
+TEST_NOT_DIFFERENCE_TYPE(A75, const volatile&&, &&);
+TEST_NOT_DIFFERENCE_TYPE(A76, const volatile&&, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A77, const volatile&&, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A78, const volatile&&, const volatile&&);
+
+TEST_NOT_DIFFERENCE_TYPE(A81, &, NO_QUALIFIER);
+// TEST_NOT_DIFFERENCE_TYPE(A82, const&, NO_QUALIFIER); // == true
+TEST_NOT_DIFFERENCE_TYPE(A83, volatile&, NO_QUALIFIER);
+// TEST_NOT_DIFFERENCE_TYPE(A84, const volatile&, NO_QUALIFIER); // invalid
+TEST_NOT_DIFFERENCE_TYPE(A85, &&, NO_QUALIFIER);
+TEST_NOT_DIFFERENCE_TYPE(A86, const&&, NO_QUALIFIER);
+TEST_NOT_DIFFERENCE_TYPE(A87, volatile&&, NO_QUALIFIER);
+TEST_NOT_DIFFERENCE_TYPE(A88, const volatile&&, NO_QUALIFIER);
+
+TEST_NOT_DIFFERENCE_TYPE(A91, NO_QUALIFIER, &);
+// TEST_NOT_DIFFERENCE_TYPE(A92, NO_QUALIFIER, const&); // == true
+TEST_NOT_DIFFERENCE_TYPE(A93, NO_QUALIFIER, volatile&);
+// TEST_NOT_DIFFERENCE_TYPE(A94, NO_QUALIFIER, const volatile&); // invalid
+TEST_NOT_DIFFERENCE_TYPE(A95, NO_QUALIFIER, &&);
+TEST_NOT_DIFFERENCE_TYPE(A96, NO_QUALIFIER, const&&);
+TEST_NOT_DIFFERENCE_TYPE(A97, NO_QUALIFIER, volatile&&);
+TEST_NOT_DIFFERENCE_TYPE(A98, NO_QUALIFIER, const volatile&&);
diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/iter_
diff erence_t.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/iter_
diff erence_t.pass.cpp
index bfb391a19c62..877b7ac07358 100644
--- a/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/iter_
diff erence_t.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/iter_
diff erence_t.pass.cpp
@@ -18,8 +18,13 @@
#include <concepts>
#include <vector>
+template <class T>
+constexpr bool has_no_iter_
diff erence_t() {
+ return !requires { typename std::iter_
diff erence_t<T>; };
+}
+
template <class T, class Expected>
-[[nodiscard]] constexpr bool check_iter_
diff erence_t() {
+constexpr bool check_iter_
diff erence_t() {
constexpr bool result = std::same_as<std::iter_
diff erence_t<T>, Expected>;
static_assert(std::same_as<std::iter_
diff erence_t<T const>, Expected> == result);
static_assert(std::same_as<std::iter_
diff erence_t<T volatile>, Expected> == result);
@@ -39,32 +44,19 @@ static_assert(check_iter_
diff erence_t<int*, std::ptr
diff _t>());
static_assert(check_iter_
diff erence_t<std::vector<int>::iterator, std::ptr
diff _t>());
struct int_subtraction {
- friend int operator-(int_subtraction, int_subtraction) noexcept;
+ friend int operator-(int_subtraction, int_subtraction);
};
static_assert(check_iter_
diff erence_t<int_subtraction, int>());
-// clang-format off
-template <class T>
-requires requires { typename std::iter_
diff erence_t<T>; }
-[[nodiscard]] constexpr bool check_no_iter_
diff erence_t() {
- return false;
-}
-// clang-format on
-
-template <class T>
-[[nodiscard]] constexpr bool check_no_iter_
diff erence_t() {
- return true;
-}
-
-static_assert(check_no_iter_
diff erence_t<void>());
-static_assert(check_no_iter_
diff erence_t<double>());
+static_assert(has_no_iter_
diff erence_t<void>());
+static_assert(has_no_iter_
diff erence_t<double>());
struct S {};
-static_assert(check_no_iter_
diff erence_t<S>());
+static_assert(has_no_iter_
diff erence_t<S>());
struct void_subtraction {
friend void operator-(void_subtraction, void_subtraction);
};
-static_assert(check_no_iter_
diff erence_t<void_subtraction>());
+static_assert(has_no_iter_
diff erence_t<void_subtraction>());
int main(int, char**) { return 0; }
diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/readable.traits/indirectly_readable_traits.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/readable.traits/indirectly_readable_traits.compile.pass.cpp
index 6cab7cf25319..bb140fb469ee 100644
--- a/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/readable.traits/indirectly_readable_traits.compile.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/readable.traits/indirectly_readable_traits.compile.pass.cpp
@@ -20,168 +20,133 @@
#include <string>
#include <vector>
-// `value_type` and `element_type` member aliases aren't actually used to declare anytihng, so GCC
-// thinks they're completely unused.
-#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
-
-// clang-format off
template <class T>
-concept check_has_value_type = requires {
+concept has_no_value_type = !requires {
typename std::indirectly_readable_traits<T>::value_type;
};
template <class T, class Expected>
-concept check_value_type_matches =
- check_has_value_type<T> &&
+concept value_type_matches =
std::same_as<typename std::indirectly_readable_traits<T>::value_type, Expected>;
-// clang-format on
template <class T>
constexpr bool check_pointer() {
- constexpr bool result = check_value_type_matches<T*, T>;
- static_assert(check_value_type_matches<T const*, T> == result);
- static_assert(check_value_type_matches<T volatile*, T> == result);
- static_assert(check_value_type_matches<T const volatile*, T> == result);
+ constexpr bool result = value_type_matches<T*, T>;
+ static_assert(value_type_matches<T const*, T> == result);
+ static_assert(value_type_matches<T volatile*, T> == result);
+ static_assert(value_type_matches<T const volatile*, T> == result);
- static_assert(check_value_type_matches<T* const, T> == result);
- static_assert(check_value_type_matches<T const* const, T> == result);
- static_assert(check_value_type_matches<T volatile* const, T> == result);
- static_assert(check_value_type_matches<T const volatile* const, T> == result);
+ static_assert(value_type_matches<T* const, T> == result);
+ static_assert(value_type_matches<T const* const, T> == result);
+ static_assert(value_type_matches<T volatile* const, T> == result);
+ static_assert(value_type_matches<T const volatile* const, T> == result);
return result;
}
-static_assert(!check_pointer<void>());
-static_assert(check_pointer<int>());
-static_assert(check_pointer<long>());
-static_assert(check_pointer<double>());
-static_assert(check_pointer<double*>());
-
-struct S {};
-static_assert(check_pointer<S>());
-
template <class T>
constexpr bool check_array() {
- constexpr bool result = check_value_type_matches<T[], T>;
- static_assert(check_value_type_matches<T const[], T> == result);
- static_assert(check_value_type_matches<T volatile[], T> == result);
- static_assert(check_value_type_matches<T const volatile[], T> == result);
- static_assert(check_value_type_matches<T[10], T> == result);
- static_assert(check_value_type_matches<T const[10], T> == result);
- static_assert(check_value_type_matches<T volatile[10], T> == result);
- static_assert(check_value_type_matches<T const volatile[10], T> == result);
- return result;
+ static_assert(value_type_matches<T[], T>);
+ static_assert(value_type_matches<T const[], T>);
+ static_assert(value_type_matches<T volatile[], T>);
+ static_assert(value_type_matches<T const volatile[], T>);
+ static_assert(value_type_matches<T[10], T>);
+ static_assert(value_type_matches<T const[10], T>);
+ static_assert(value_type_matches<T volatile[10], T>);
+ static_assert(value_type_matches<T const volatile[10], T>);
+ return true;
}
-static_assert(check_array<int>());
-static_assert(check_array<long>());
-static_assert(check_array<double>());
-static_assert(check_array<double*>());
-static_assert(check_array<S>());
-
template <class T, class Expected>
-constexpr bool check_explicit_member() {
- constexpr bool result = check_value_type_matches<T, Expected>;
- static_assert(check_value_type_matches<T const, Expected> == result);
- return result;
+constexpr bool check_member() {
+ static_assert(value_type_matches<T, Expected>);
+ static_assert(value_type_matches<T const, Expected>);
+ static_assert(value_type_matches<T volatile, Expected>);
+ return true;
}
-struct has_value_type {
- using value_type = int;
-};
-static_assert(check_explicit_member<has_value_type, int>());
-static_assert(check_explicit_member<std::vector<int>::iterator, int>());
+static_assert(check_pointer<int>());
+static_assert(check_pointer<int*>());
+static_assert(check_pointer<int[10]>());
+static_assert(!check_pointer<void>());
+static_assert(!check_pointer<int()>());
-struct has_element_type {
- using element_type = S;
+static_assert(check_array<int>());
+static_assert(check_array<int*>());
+static_assert(check_array<int[10]>());
+
+template<class T>
+struct ValueOf {
+ using value_type = T;
};
-static_assert(check_explicit_member<has_element_type, S>());
-struct has_same_value_and_element_type {
- using value_type = int;
- using element_type = int;
+template<class U>
+struct ElementOf {
+ using element_type = U;
};
-static_assert(check_explicit_member<has_same_value_and_element_type, int>());
-static_assert(check_explicit_member<std::shared_ptr<long>, long>());
-static_assert(check_explicit_member<std::shared_ptr<long const>, long>());
-// clang-format off
template<class T, class U>
-requires std::same_as<std::remove_cv_t<T>, std::remove_cv_t<U> >
-struct possibly_
diff erent_cv_qualifiers {
+struct TwoTypes {
using value_type = T;
using element_type = U;
};
-// clang-format on
-
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int, int>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int, int const>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int, int volatile>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int, int const volatile>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const, int>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const, int const>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const, int volatile>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const, int const volatile>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int volatile, int>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int volatile, int const>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int volatile, int volatile>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int volatile, int const volatile>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const volatile, int>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const volatile, int const>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const volatile, int volatile>, int>());
-static_assert(check_explicit_member<possibly_
diff erent_cv_qualifiers<int const volatile, int const volatile>, int>());
+
+static_assert(check_member<ValueOf<int>, int>());
+static_assert(check_member<ValueOf<int[10]>, int[10]>());
+static_assert(check_member<ValueOf<int[]>, int[]>());
+static_assert(has_no_value_type<ValueOf<void>>);
+static_assert(has_no_value_type<ValueOf<int()>>);
+static_assert(has_no_value_type<ValueOf<int&>>);
+static_assert(has_no_value_type<ValueOf<int&&>>);
+
+static_assert(check_member<ElementOf<int>, int>());
+static_assert(check_member<ElementOf<int[10]>, int[10]>());
+static_assert(check_member<ElementOf<int[]>, int[]>());
+static_assert(has_no_value_type<ElementOf<void>>);
+static_assert(has_no_value_type<ElementOf<int()>>);
+static_assert(has_no_value_type<ElementOf<int&>>);
+static_assert(has_no_value_type<ElementOf<int&&>>);
+
+static_assert(check_member<TwoTypes<int, int>, int>());
+static_assert(check_member<TwoTypes<int, int const>, int>());
+static_assert(check_member<TwoTypes<int, int volatile>, int>());
+static_assert(check_member<TwoTypes<int, int const volatile>, int>());
+static_assert(check_member<TwoTypes<int const, int>, int>());
+static_assert(check_member<TwoTypes<int const, int const>, int>());
+static_assert(check_member<TwoTypes<int const, int volatile>, int>());
+static_assert(check_member<TwoTypes<int const, int const volatile>, int>());
+static_assert(check_member<TwoTypes<int volatile, int>, int>());
+static_assert(check_member<TwoTypes<int volatile, int const>, int>());
+static_assert(check_member<TwoTypes<int volatile, int volatile>, int>());
+static_assert(check_member<TwoTypes<int volatile, int const volatile>, int>());
+static_assert(check_member<TwoTypes<int const volatile, int>, int>());
+static_assert(check_member<TwoTypes<int const volatile, int const>, int>());
+static_assert(check_member<TwoTypes<int const volatile, int volatile>, int>());
+static_assert(check_member<TwoTypes<int const volatile, int const volatile>, int>());
+static_assert(has_no_value_type<TwoTypes<int, long>>);
+static_assert(has_no_value_type<TwoTypes<int, int&>>);
+static_assert(has_no_value_type<TwoTypes<int&, int>>);
struct S2 {};
-namespace std {
template <>
-struct indirectly_readable_traits<S2> {
+struct std::indirectly_readable_traits<S2> {
using value_type = int;
};
-} // namespace std
-static_assert(check_value_type_matches<S2, int>);
-static_assert(check_value_type_matches<std::vector<int>, int>);
-static_assert(check_value_type_matches<std::vector<int>::iterator, int>);
-static_assert(check_value_type_matches<std::vector<int>::const_iterator, int>);
-static_assert(check_value_type_matches<std::istream_iterator<int>, int>);
-static_assert(check_value_type_matches<std::istreambuf_iterator<char>, char>);
-static_assert(check_value_type_matches<std::optional<int>, int>);
-
-template <class T>
-constexpr bool check_ref() {
- struct ref_value {
- using value_type = T&;
- };
- constexpr bool result = check_has_value_type<ref_value>;
-
- struct ref_element {
- using element_type = T&;
- };
- static_assert(check_has_value_type<ref_element> == result);
-
- return result;
-}
-
-static_assert(!check_ref<int>());
-static_assert(!check_ref<S>());
-static_assert(!check_ref<std::shared_ptr<long> >());
-
-static_assert(!check_has_value_type<void>);
-static_assert(!check_has_value_type<std::nullptr_t>);
-static_assert(!check_has_value_type<int>);
-static_assert(!check_has_value_type<S>);
-
-struct has_
diff erent_value_and_element_type {
- using value_type = int;
- using element_type = long;
-};
-static_assert(!check_has_value_type<has_
diff erent_value_and_element_type>);
-
-struct void_value {
- using value_type = void;
-};
-static_assert(!check_has_value_type<void_value>);
-
-struct void_element {
- using element_type = void;
-};
-static_assert(!check_has_value_type<void_element>);
+static_assert(value_type_matches<S2, int>);
+static_assert(value_type_matches<const S2, int>);
+static_assert(has_no_value_type<volatile S2>);
+static_assert(has_no_value_type<const volatile S2>);
+static_assert(has_no_value_type<S2&>);
+static_assert(has_no_value_type<const S2&>);
+
+static_assert(check_member<std::vector<int>, int>());
+static_assert(check_member<std::vector<int>::iterator, int>());
+static_assert(check_member<std::vector<int>::const_iterator, int>());
+static_assert(check_member<std::istream_iterator<int>, int>());
+static_assert(check_member<std::istreambuf_iterator<char>, char>());
+static_assert(check_member<std::optional<int>, int>());
+static_assert(check_member<std::shared_ptr<long>, long>());
+static_assert(check_member<std::shared_ptr<const long>, long>());
+static_assert(has_no_value_type<void>);
+static_assert(has_no_value_type<int>);
+static_assert(has_no_value_type<std::nullptr_t>);
More information about the libcxx-commits
mailing list