[libcxx-commits] [libcxx] 2d13302 - [libc++][test] Confirm that P0508R0 has been implemented (#108172)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 16 12:34:44 PDT 2024
Author: A. Jiang
Date: 2024-09-16T15:34:40-04:00
New Revision: 2d13302d3851747a023ffecc6388585e888cd0e9
URL: https://github.com/llvm/llvm-project/commit/2d13302d3851747a023ffecc6388585e888cd0e9
DIFF: https://github.com/llvm/llvm-project/commit/2d13302d3851747a023ffecc6388585e888cd0e9.diff
LOG: [libc++][test] Confirm that P0508R0 has been implemented (#108172)
The paper was implemented by commit b0386a515b60c
(https://reviews.llvm.org/D46845) in LLVM 7.0. But it would be nice to
have test coverage for desired properties of `insert_return_type`.
Closes #99944
Added:
Modified:
libcxx/docs/Status/Cxx17Papers.csv
libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp
libcxx/test/std/containers/unord/unord.set/insert_node_type.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv
index 3dd386a8a1ee18..3b56807312d556 100644
--- a/libcxx/docs/Status/Cxx17Papers.csv
+++ b/libcxx/docs/Status/Cxx17Papers.csv
@@ -81,7 +81,7 @@
"`P0503R0 <https://wg21.link/P0503R0>`__","Correcting library usage of ""literal type""","2016-11 (Issaquah)","|Complete|","4.0",""
"`P0504R0 <https://wg21.link/P0504R0>`__","Revisiting in-place tag types for any/optional/variant","2016-11 (Issaquah)","|Complete|","4.0",""
"`P0505R0 <https://wg21.link/P0505R0>`__","Wording for GB 50 - constexpr for chrono","2016-11 (Issaquah)","|Complete|","4.0",""
-"`P0508R0 <https://wg21.link/P0508R0>`__","Wording for GB 58 - structured bindings for node_handles","2016-11 (Issaquah)","","",""
+"`P0508R0 <https://wg21.link/P0508R0>`__","Wording for GB 58 - structured bindings for node_handles","2016-11 (Issaquah)","|Complete|","7.0",""
"`P0509R1 <https://wg21.link/P0509R1>`__","Updating ""Restrictions on exception handling""","2016-11 (Issaquah)","|Nothing To Do|","n/a",""
"`P0510R0 <https://wg21.link/P0510R0>`__","Disallowing references, incomplete types, arrays, and empty variants","2016-11 (Issaquah)","|Complete|","4.0",""
"`P0513R0 <https://wg21.link/P0513R0>`__","Poisoning the Hash","2016-11 (Issaquah)","|Complete|","5.0",""
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
index 6445cd87858a26..5d910bc3368bed 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
@@ -15,10 +15,32 @@
// insert_return_type insert(node_type&&);
#include <map>
+#include <memory>
#include <type_traits>
#include "test_macros.h"
#include "min_allocator.h"
+template <class Container, class T>
+void verify_insert_return_type(T&& t) {
+ using verified_type = std::remove_cv_t<std::remove_reference_t<T>>;
+ static_assert(std::is_aggregate_v<verified_type>);
+ static_assert(std::is_same_v<verified_type, typename Container::insert_return_type>);
+
+ auto& [pos, ins, nod] = t;
+
+ static_assert(std::is_same_v<decltype(pos), typename Container::iterator>);
+ static_assert(std::is_same_v<decltype(t.position), typename Container::iterator>);
+ assert(std::addressof(pos) == std::addressof(t.position));
+
+ static_assert(std::is_same_v<decltype(ins), bool>);
+ static_assert(std::is_same_v<decltype(t.inserted), bool>);
+ assert(&ins == &t.inserted);
+
+ static_assert(std::is_same_v<decltype(nod), typename Container::node_type>);
+ static_assert(std::is_same_v<decltype(t.node), typename Container::node_type>);
+ assert(std::addressof(nod) == std::addressof(t.node));
+}
+
template <class Container>
typename Container::node_type
node_factory(typename Container::key_type const& key,
@@ -44,6 +66,7 @@ void test(Container& c)
assert(irt.inserted);
assert(irt.node.empty());
assert(irt.position->first == i && irt.position->second == i + 1);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
@@ -55,6 +78,7 @@ void test(Container& c)
assert(!irt.inserted);
assert(irt.node.empty());
assert(irt.position == c.end());
+ verify_insert_return_type<Container>(irt);
}
{ // Insert duplicate node.
@@ -65,6 +89,7 @@ void test(Container& c)
assert(!irt.node.empty());
assert(irt.position == c.find(0));
assert(irt.node.key() == 0 && irt.node.mapped() == 42);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
diff --git a/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp b/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
index eac48203484b5e..69caecffef8852 100644
--- a/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
@@ -14,11 +14,33 @@
// insert_return_type insert(node_type&&);
+#include <memory>
#include <set>
#include <type_traits>
#include "test_macros.h"
#include "min_allocator.h"
+template <class Container, class T>
+void verify_insert_return_type(T&& t) {
+ using verified_type = std::remove_cv_t<std::remove_reference_t<T>>;
+ static_assert(std::is_aggregate_v<verified_type>);
+ static_assert(std::is_same_v<verified_type, typename Container::insert_return_type>);
+
+ auto& [pos, ins, nod] = t;
+
+ static_assert(std::is_same_v<decltype(pos), typename Container::iterator>);
+ static_assert(std::is_same_v<decltype(t.position), typename Container::iterator>);
+ assert(std::addressof(pos) == std::addressof(t.position));
+
+ static_assert(std::is_same_v<decltype(ins), bool>);
+ static_assert(std::is_same_v<decltype(t.inserted), bool>);
+ assert(&ins == &t.inserted);
+
+ static_assert(std::is_same_v<decltype(nod), typename Container::node_type>);
+ static_assert(std::is_same_v<decltype(t.node), typename Container::node_type>);
+ assert(std::addressof(nod) == std::addressof(t.node));
+}
+
template <class Container>
typename Container::node_type
node_factory(typename Container::key_type const& key)
@@ -43,6 +65,7 @@ void test(Container& c)
assert(irt.inserted);
assert(irt.node.empty());
assert(*irt.position == i);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
@@ -54,6 +77,7 @@ void test(Container& c)
assert(!irt.inserted);
assert(irt.node.empty());
assert(irt.position == c.end());
+ verify_insert_return_type<Container>(irt);
}
{ // Insert duplicate node.
@@ -64,6 +88,7 @@ void test(Container& c)
assert(!irt.node.empty());
assert(irt.position == c.find(0));
assert(irt.node.value() == 0);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp
index 2d15ee179c23b4..7188774466969e 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp
@@ -14,10 +14,32 @@
// insert_return_type insert(node_type&&);
+#include <memory>
#include <unordered_map>
#include "test_macros.h"
#include "min_allocator.h"
+template <class Container, class T>
+void verify_insert_return_type(T&& t) {
+ using verified_type = std::remove_cv_t<std::remove_reference_t<T>>;
+ static_assert(std::is_aggregate_v<verified_type>);
+ static_assert(std::is_same_v<verified_type, typename Container::insert_return_type>);
+
+ auto& [pos, ins, nod] = t;
+
+ static_assert(std::is_same_v<decltype(pos), typename Container::iterator>);
+ static_assert(std::is_same_v<decltype(t.position), typename Container::iterator>);
+ assert(std::addressof(pos) == std::addressof(t.position));
+
+ static_assert(std::is_same_v<decltype(ins), bool>);
+ static_assert(std::is_same_v<decltype(t.inserted), bool>);
+ assert(&ins == &t.inserted);
+
+ static_assert(std::is_same_v<decltype(nod), typename Container::node_type>);
+ static_assert(std::is_same_v<decltype(t.node), typename Container::node_type>);
+ assert(std::addressof(nod) == std::addressof(t.node));
+}
+
template <class Container>
typename Container::node_type
node_factory(typename Container::key_type const& key,
@@ -43,6 +65,7 @@ void test(Container& c)
assert(irt.inserted);
assert(irt.node.empty());
assert(irt.position->first == i && irt.position->second == i + 1);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
@@ -54,6 +77,7 @@ void test(Container& c)
assert(!irt.inserted);
assert(irt.node.empty());
assert(irt.position == c.end());
+ verify_insert_return_type<Container>(irt);
}
{ // Insert duplicate node.
@@ -64,6 +88,7 @@ void test(Container& c)
assert(!irt.node.empty());
assert(irt.position == c.find(0));
assert(irt.node.key() == 0 && irt.node.mapped() == 42);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_node_type.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_node_type.pass.cpp
index a4ae313d8e301a..16f52f456fbff4 100644
--- a/libcxx/test/std/containers/unord/unord.set/insert_node_type.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/insert_node_type.pass.cpp
@@ -14,11 +14,33 @@
// insert_return_type insert(node_type&&);
+#include <memory>
#include <unordered_set>
#include <type_traits>
#include "test_macros.h"
#include "min_allocator.h"
+template <class Container, class T>
+void verify_insert_return_type(T&& t) {
+ using verified_type = std::remove_cv_t<std::remove_reference_t<T>>;
+ static_assert(std::is_aggregate_v<verified_type>);
+ static_assert(std::is_same_v<verified_type, typename Container::insert_return_type>);
+
+ auto& [pos, ins, nod] = t;
+
+ static_assert(std::is_same_v<decltype(pos), typename Container::iterator>);
+ static_assert(std::is_same_v<decltype(t.position), typename Container::iterator>);
+ assert(std::addressof(pos) == std::addressof(t.position));
+
+ static_assert(std::is_same_v<decltype(ins), bool>);
+ static_assert(std::is_same_v<decltype(t.inserted), bool>);
+ assert(&ins == &t.inserted);
+
+ static_assert(std::is_same_v<decltype(nod), typename Container::node_type>);
+ static_assert(std::is_same_v<decltype(t.node), typename Container::node_type>);
+ assert(std::addressof(nod) == std::addressof(t.node));
+}
+
template <class Container>
typename Container::node_type
node_factory(typename Container::key_type const& key)
@@ -43,6 +65,7 @@ void test(Container& c)
assert(irt.inserted);
assert(irt.node.empty());
assert(*irt.position == i);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
@@ -54,6 +77,7 @@ void test(Container& c)
assert(!irt.inserted);
assert(irt.node.empty());
assert(irt.position == c.end());
+ verify_insert_return_type<Container>(irt);
}
{ // Insert duplicate node.
@@ -64,6 +88,7 @@ void test(Container& c)
assert(!irt.node.empty());
assert(irt.position == c.find(0));
assert(irt.node.value() == 0);
+ verify_insert_return_type<Container>(irt);
}
assert(c.size() == 10);
More information about the libcxx-commits
mailing list