[libcxx-commits] [libcxx] [libc++] Make `<map>` `std::multimap` constexpr as part of P3372R3 (PR #161901)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 18 08:29:25 PDT 2026


================
@@ -12,27 +12,27 @@
 
 // class multimap
 
-// iterator insert(node_type&&);
+// iterator insert(node_type&&); // constexpr since C++26
 
 #include <map>
 #include <type_traits>
 #include "test_macros.h"
 #include "min_allocator.h"
 
 template <class Container>
-typename Container::node_type
-node_factory(typename Container::key_type const& key, typename Container::mapped_type const& mapped) {
-  static Container c;
+TEST_CONSTEXPR_CXX26 typename Container::node_type
+node_factory(Container& c, typename Container::key_type const& key, typename Container::mapped_type const& mapped) {
   auto it = c.insert({key, mapped});
   return c.extract(it);
 }
 
 template <class Container>
-void test(Container& c) {
+TEST_CONSTEXPR_CXX26 void test(Container& c) {
   auto* nf = &node_factory<Container>;
+  Container c2;
 
   for (int i = 0; i != 10; ++i) {
-    typename Container::node_type node = nf(i, i + 1);
+    auto node = nf(c2, i, i + 1);
----------------
ldionne wrote:

Why was that changed? This weakens the test since we're not asserting the type anymore.

https://github.com/llvm/llvm-project/pull/161901


More information about the libcxx-commits mailing list