[libcxx-commits] [libcxx] 7013b51 - [libc++] Implement `std::flat_multiset` (#128363)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 6 02:51:00 PDT 2025


Author: Hui
Date: 2025-04-06T10:50:55+01:00
New Revision: 7013b51548c0bd2c7e5564735c44506909a2f8dc

URL: https://github.com/llvm/llvm-project/commit/7013b51548c0bd2c7e5564735c44506909a2f8dc
DIFF: https://github.com/llvm/llvm-project/commit/7013b51548c0bd2c7e5564735c44506909a2f8dc.diff

LOG: [libc++] Implement `std::flat_multiset` (#128363)

fixes https://github.com/llvm/llvm-project/issues/105193

Added: 
    libcxx/include/__flat_set/flat_multiset.h
    libcxx/include/__flat_set/utils.h
    libcxx/test/libcxx/containers/container.adaptors/flat.multiset/assert.sorted_unique.pass.cpp
    libcxx/test/libcxx/containers/container.adaptors/flat.multiset/iterator.compile.pass.cpp
    libcxx/test/libcxx/diagnostics/flat_multiset.nodiscard.verify.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/empty.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/max_size.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/size.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/alloc.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/assign_initializer_list.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/compare.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/containers.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_alloc.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_assign.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.compile.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct_pmr.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/initializer_list.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/iter_iter.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_alloc.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_assign.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/pmr.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/range.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_container.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_initializer_list.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_iter_iter.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if_exceptions.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_comparison.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_concept_conformance.compile.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/range_concept_conformance.compile.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/reverse_iterator.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/clear.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace_hint.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter_iter.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key_transparent.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/extract.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_cv.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_initializer_list.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_cv.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_iter.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_rv.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_range.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_rv.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_initializer_list.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_iter_iter.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/replace.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_exception.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_free.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_member.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.observers/comp.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains_transparent.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count_transparent.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range_transparent.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find_transparent.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound_transparent.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound_transparent.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/helpers.h
    libcxx/test/std/containers/container.adaptors/flat.multiset/incomplete_type.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/op_compare.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat.multiset/types.compile.pass.cpp
    libcxx/test/std/containers/container.adaptors/flat_helpers.h

Modified: 
    libcxx/docs/FeatureTestMacroTable.rst
    libcxx/docs/ReleaseNotes/21.rst
    libcxx/docs/Status/Cxx23Papers.csv
    libcxx/include/CMakeLists.txt
    libcxx/include/__flat_set/flat_set.h
    libcxx/include/flat_set
    libcxx/include/module.modulemap
    libcxx/include/version
    libcxx/modules/std/flat_set.inc
    libcxx/test/std/containers/container.adaptors/flat.map/helpers.h
    libcxx/test/std/containers/container.adaptors/flat.multimap/helpers.h
    libcxx/test/std/containers/container.adaptors/flat.set/helpers.h
    libcxx/test/std/language.support/support.limits/support.limits.general/flat_set.version.compile.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
    libcxx/utils/generate_feature_test_macro_components.py
    libcxx/utils/libcxx/test/modules.py

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 9015ccb18dddf..bf25b34ba9159 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -332,7 +332,7 @@ Status
     ---------------------------------------------------------- -----------------
     ``__cpp_lib_flat_map``                                     ``202207L``
     ---------------------------------------------------------- -----------------
-    ``__cpp_lib_flat_set``                                     *unimplemented*
+    ``__cpp_lib_flat_set``                                     ``202207L``
     ---------------------------------------------------------- -----------------
     ``__cpp_lib_format_ranges``                                ``202207L``
     ---------------------------------------------------------- -----------------

diff  --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index 7af109ddc8657..1f479d19e4772 100644
--- a/libcxx/docs/ReleaseNotes/21.rst
+++ b/libcxx/docs/ReleaseNotes/21.rst
@@ -43,8 +43,8 @@ Implemented Papers
 - P1361R2: Integration of chrono with text formatting (`Github <https://github.com/llvm/llvm-project/issues/100014>`__)
 - P2255R2: A type trait to detect reference binding to temporary (implemented the type traits only) (`Github <https://github.com/llvm/llvm-project/issues/105180>`__)
 - P2562R1: ``constexpr`` Stable Sorting (`Github <https://github.com/llvm/llvm-project/issues/105360>`__)
-- P1222R4: A Standard ``flat_set`` is partially implemented and ``flat_set`` is provided (`Github <https://github.com/llvm/llvm-project/issues/105193>`__)
 - P0472R3: Put std::monostate in <utility> (`Github <https://github.com/llvm/llvm-project/issues/127874>`__)
+- P1222R4: A Standard ``flat_set`` (`Github <https://github.com/llvm/llvm-project/issues/105193>`__)
 
 Improvements and New Features
 -----------------------------

diff  --git a/libcxx/docs/Status/Cxx23Papers.csv b/libcxx/docs/Status/Cxx23Papers.csv
index 923d8bf9341d0..c26363bcda796 100644
--- a/libcxx/docs/Status/Cxx23Papers.csv
+++ b/libcxx/docs/Status/Cxx23Papers.csv
@@ -54,7 +54,7 @@
 "`P0009R18 <https://wg21.link/P0009R18>`__","mdspan: A Non-Owning Multidimensional Array Reference","2022-07 (Virtual)","|Complete|","18",""
 "`P0429R9 <https://wg21.link/P0429R9>`__","A Standard ``flat_map``","2022-07 (Virtual)","|Complete|","20",""
 "`P1169R4 <https://wg21.link/P1169R4>`__","``static operator()``","2022-07 (Virtual)","|Complete|","16",""
-"`P1222R4 <https://wg21.link/P1222R4>`__","A Standard ``flat_set``","2022-07 (Virtual)","|In progress|","",""
+"`P1222R4 <https://wg21.link/P1222R4>`__","A Standard ``flat_set``","2022-07 (Virtual)","|Complete|","21",""
 "`P1223R5 <https://wg21.link/P1223R5>`__","``ranges::find_last()``, ``ranges::find_last_if()``, and ``ranges::find_last_if_not()``","2022-07 (Virtual)","|Complete|","19",""
 "`P1467R9 <https://wg21.link/P1467R9>`__","Extended ``floating-point`` types and standard names","2022-07 (Virtual)","","",""
 "`P1642R11 <https://wg21.link/P1642R11>`__","Freestanding ``[utilities]``, ``[ranges]``, and ``[iterators]``","2022-07 (Virtual)","","",""

diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 7b09beb74b173..0429c90b01a76 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -370,8 +370,10 @@ set(files
   __flat_map/sorted_equivalent.h
   __flat_map/sorted_unique.h
   __flat_map/utils.h
+  __flat_set/flat_multiset.h
   __flat_set/flat_set.h
   __flat_set/ra_iterator.h
+  __flat_set/utils.h
   __format/buffer.h
   __format/concepts.h
   __format/container_adaptor.h

diff  --git a/libcxx/include/__flat_set/flat_multiset.h b/libcxx/include/__flat_set/flat_multiset.h
new file mode 100644
index 0000000000000..0fed377b25e5a
--- /dev/null
+++ b/libcxx/include/__flat_set/flat_multiset.h
@@ -0,0 +1,792 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FLAT_MAP_FLAT_MULTISET_H
+#define _LIBCPP___FLAT_MAP_FLAT_MULTISET_H
+
+#include <__algorithm/equal_range.h>
+#include <__algorithm/lexicographical_compare_three_way.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/min.h>
+#include <__algorithm/ranges_equal.h>
+#include <__algorithm/ranges_inplace_merge.h>
+#include <__algorithm/ranges_is_sorted.h>
+#include <__algorithm/ranges_sort.h>
+#include <__algorithm/ranges_unique.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/upper_bound.h>
+#include <__assert>
+#include <__compare/synth_three_way.h>
+#include <__concepts/convertible_to.h>
+#include <__concepts/swappable.h>
+#include <__config>
+#include <__cstddef/byte.h>
+#include <__cstddef/ptr
diff _t.h>
+#include <__flat_map/key_value_iterator.h>
+#include <__flat_map/sorted_equivalent.h>
+#include <__flat_set/ra_iterator.h>
+#include <__flat_set/utils.h>
+#include <__functional/invoke.h>
+#include <__functional/is_transparent.h>
+#include <__functional/operations.h>
+#include <__fwd/vector.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/prev.h>
+#include <__iterator/ranges_iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/uses_allocator.h>
+#include <__memory/uses_allocator_construction.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/container_compatible_range.h>
+#include <__ranges/drop_view.h>
+#include <__ranges/from_range.h>
+#include <__ranges/ref_view.h>
+#include <__ranges/size.h>
+#include <__ranges/subrange.h>
+#include <__ranges/zip_view.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/container_traits.h>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_allocator.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/as_const.h>
+#include <__utility/exception_guard.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <__utility/scope_guard.h>
+#include <__vector/vector.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Key, class _Compare = less<_Key>, class _KeyContainer = vector<_Key>>
+class flat_multiset {
+  template <class, class, class>
+  friend class flat_multiset;
+
+  friend __flat_set_utils;
+
+  static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
+  static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
+
+public:
+  // types
+  using key_type               = _Key;
+  using value_type             = _Key;
+  using key_compare            = __type_identity_t<_Compare>;
+  using value_compare          = _Compare;
+  using reference              = value_type&;
+  using const_reference        = const value_type&;
+  using size_type              = typename _KeyContainer::size_type;
+  using 
diff erence_type        = typename _KeyContainer::
diff erence_type;
+  using iterator               = __ra_iterator<flat_multiset, typename _KeyContainer::const_iterator>;
+  using const_iterator         = iterator;
+  using reverse_iterator       = std::reverse_iterator<iterator>;
+  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+  using container_type         = _KeyContainer;
+
+public:
+  // [flat.multiset.cons], constructors
+  _LIBCPP_HIDE_FROM_ABI flat_multiset() noexcept(is_nothrow_default_constructible_v<_KeyContainer> &&
+                                                 is_nothrow_default_constructible_v<_Compare>)
+      : __keys_(), __compare_() {}
+
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset&) = default;
+
+  // The copy/move constructors are not specified in the spec, which means they should be defaulted.
+  // However, the move constructor can potentially leave a moved-from object in an inconsistent
+  // state if an exception is thrown.
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other) noexcept(
+      is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)
+#  if _LIBCPP_HAS_EXCEPTIONS
+      try
+#  endif // _LIBCPP_HAS_EXCEPTIONS
+      : __keys_(std::move(__other.__keys_)), __compare_(std::move(__other.__compare_)) {
+    __other.clear();
+#  if _LIBCPP_HAS_EXCEPTIONS
+  } catch (...) {
+    __other.clear();
+    // gcc does not like the `throw` keyword in a conditionally noexcept function
+    if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)) {
+      throw;
+    }
+#  endif // _LIBCPP_HAS_EXCEPTIONS
+  }
+
+  _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const key_compare& __comp) : __keys_(), __compare_(__comp) {}
+
+  _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(container_type __keys, const key_compare& __comp = key_compare())
+      : __keys_(std::move(__keys)), __compare_(__comp) {
+    ranges::sort(__keys_, __compare_);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(sorted_equivalent_t, container_type __keys, const key_compare& __comp = key_compare())
+      : __keys_(std::move(__keys)), __compare_(__comp) {
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
+  }
+
+  template <class _InputIterator>
+    requires __has_input_iterator_category<_InputIterator>::value
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
+      : __keys_(), __compare_(__comp) {
+    insert(__first, __last);
+  }
+
+  template <class _InputIterator>
+    requires __has_input_iterator_category<_InputIterator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(
+      sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
+      : __keys_(__first, __last), __compare_(__comp) {
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
+  }
+
+  template <_ContainerCompatibleRange<value_type> _Range>
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t __fr, _Range&& __rg)
+      : flat_multiset(__fr, std::forward<_Range>(__rg), key_compare()) {}
+
+  template <_ContainerCompatibleRange<value_type> _Range>
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_multiset(__comp) {
+    insert_range(std::forward<_Range>(__rg));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
+      : flat_multiset(__il.begin(), __il.end(), __comp) {}
+
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())
+      : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp) {}
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {}
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(const key_compare& __comp, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {}
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(const container_type& __keys, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
+    ranges::sort(__keys_, __compare_);
+  }
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
+    ranges::sort(__keys_, __compare_);
+  }
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, const container_type& __keys, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
+  }
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(sorted_equivalent_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
+  }
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset& __other, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)),
+        __compare_(__other.__compare_) {}
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other, const _Allocator& __alloc)
+#  if _LIBCPP_HAS_EXCEPTIONS
+      try
+#  endif // _LIBCPP_HAS_EXCEPTIONS
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, std::move(__other.__keys_))),
+        __compare_(std::move(__other.__compare_)) {
+    __other.clear();
+#  if _LIBCPP_HAS_EXCEPTIONS
+  } catch (...) {
+    __other.clear();
+    throw;
+#  endif // _LIBCPP_HAS_EXCEPTIONS
+  }
+
+  template <class _InputIterator, class _Allocator>
+    requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
+    insert(__first, __last);
+  }
+
+  template <class _InputIterator, class _Allocator>
+    requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
+    insert(__first, __last);
+  }
+
+  template <class _InputIterator, class _Allocator>
+    requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() {
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
+  }
+
+  template <class _InputIterator, class _Allocator>
+    requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(sorted_equivalent_t,
+                _InputIterator __first,
+                _InputIterator __last,
+                const key_compare& __comp,
+                const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) {
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
+  }
+
+  template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
+    insert_range(std::forward<_Range>(__rg));
+  }
+
+  template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
+      : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
+    insert_range(std::forward<_Range>(__rg));
+  }
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const _Allocator& __alloc)
+      : flat_multiset(__il.begin(), __il.end(), __alloc) {}
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI
+  flat_multiset(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
+      : flat_multiset(__il.begin(), __il.end(), __comp, __alloc) {}
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc)
+      : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __alloc) {}
+
+  template <class _Allocator>
+    requires uses_allocator<container_type, _Allocator>::value
+  _LIBCPP_HIDE_FROM_ABI flat_multiset(
+      sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
+      : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {}
+
+  _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(initializer_list<value_type> __il) {
+    clear();
+    insert(__il);
+    return *this;
+  }
+
+  // copy/move assignment are not specified in the spec (defaulted)
+  // but move assignment can potentially leave moved from object in an inconsistent
+  // state if an exception is thrown
+  _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(const flat_multiset&) = default;
+
+  _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(flat_multiset&& __other) noexcept(
+      is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) {
+    auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; });
+    auto __clear_self_guard  = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
+    __keys_                  = std::move(__other.__keys_);
+    __compare_               = std::move(__other.__compare_);
+    __clear_self_guard.__complete();
+    return *this;
+  }
+
+  // iterators
+  _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { return iterator(std::as_const(__keys_).begin()); }
+  _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return const_iterator(__keys_.begin()); }
+  _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { return iterator(std::as_const(__keys_).end()); }
+  _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return const_iterator(__keys_.end()); }
+
+  _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
+  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
+  _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
+  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
+
+  _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); }
+  _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); }
+  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
+  _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
+
+  // capacity
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __keys_.empty(); }
+  _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __keys_.size(); }
+  _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { return __keys_.max_size(); }
+
+  // [flat.multiset.modifiers], modifiers
+  template <class... _Args>
+    requires is_constructible_v<value_type, _Args...>
+  _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
+    if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
+      return __emplace(std::forward<_Args>(__args)...);
+    } else {
+      return __emplace(_Key(std::forward<_Args>(__args)...));
+    }
+  }
+
+  template <class... _Args>
+    requires is_constructible_v<value_type, _Args...>
+  _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
+    if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
+      return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...);
+    } else {
+      return __emplace_hint(std::move(__hint), _Key(std::forward<_Args>(__args)...));
+    }
+  }
+
+  _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return emplace(__x); }
+
+  _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return emplace(std::move(__x)); }
+
+  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) {
+    return emplace_hint(__hint, __x);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) {
+    return emplace_hint(__hint, std::move(__x));
+  }
+
+  template <class _InputIterator>
+    requires __has_input_iterator_category<_InputIterator>::value
+  _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
+    if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
+      __reserve(__last - __first);
+    }
+    __append_sort_merge</*WasSorted = */ false>(std::move(__first), std::move(__last));
+  }
+
+  template <class _InputIterator>
+    requires __has_input_iterator_category<_InputIterator>::value
+  _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) {
+    if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
+      __reserve(__last - __first);
+    }
+
+    __append_sort_merge</*WasSorted = */ true>(std::move(__first), std::move(__last));
+  }
+
+  template <_ContainerCompatibleRange<value_type> _Range>
+  _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
+    if constexpr (ranges::sized_range<_Range>) {
+      __reserve(ranges::size(__range));
+    }
+
+    __append_sort_merge</*WasSorted = */ false>(std::forward<_Range>(__range));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
+
+  _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, initializer_list<value_type> __il) {
+    insert(sorted_equivalent, __il.begin(), __il.end());
+  }
+
+  _LIBCPP_HIDE_FROM_ABI container_type extract() && {
+    auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
+    auto __ret   = std::move(__keys_);
+    return __ret;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI void replace(container_type&& __keys) {
+    _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys, __compare_), "Key container is not sorted");
+    auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
+    __keys_      = std::move(__keys);
+    __guard.__complete();
+  }
+
+  _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) {
+    auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
+    auto __key_iter   = __keys_.erase(__position.__base());
+    __on_failure.__complete();
+    return iterator(__key_iter);
+  }
+
+  // The following overload is the same as the iterator overload
+  // iterator erase(const_iterator __position);
+
+  _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) {
+    auto [__first, __last] = equal_range(__x);
+    auto __res             = __last - __first;
+    erase(__first, __last);
+    return __res;
+  }
+
+  template <class _Kp>
+    requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> &&
+             !is_convertible_v<_Kp &&, const_iterator>)
+  _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) {
+    auto [__first, __last] = equal_range(__x);
+    auto __res             = __last - __first;
+    erase(__first, __last);
+    return __res;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
+    auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
+    auto __key_it     = __keys_.erase(__first.__base(), __last.__base());
+    __on_failure.__complete();
+    return iterator(std::move(__key_it));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __y) noexcept {
+    // warning: The spec has unconditional noexcept, which means that
+    // if any of the following functions throw an exception,
+    // std::terminate will be called
+    // This is discussed in P3567, which hasn't been voted on yet.
+    ranges::swap(__compare_, __y.__compare_);
+    ranges::swap(__keys_, __y.__keys_);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI void clear() noexcept { __keys_.clear(); }
+
+  // observers
+  _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; }
+  _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __compare_; }
+
+  // map operations
+  _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); }
+
+  _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) {
+    return __find_impl(*this, __x);
+  }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const {
+    return __find_impl(*this, __x);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const {
+    auto [__first, __last] = equal_range(__x);
+    return __last - __first;
+  }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const {
+    auto [__first, __last] = equal_range(__x);
+    return __last - __first;
+  }
+
+  _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const {
+    return find(__x) != end();
+  }
+
+  _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) {
+    const auto& __keys = __keys_;
+    return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const {
+    return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
+  }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) {
+    const auto& __keys = __keys_;
+    return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
+  }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const {
+    return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) {
+    const auto& __keys = __keys_;
+    return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const {
+    return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
+  }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) {
+    const auto& __keys = __keys_;
+    return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
+  }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const {
+    return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) {
+    return __equal_range_impl(*this, __x);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
+    return __equal_range_impl(*this, __x);
+  }
+
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) {
+    return __equal_range_impl(*this, __x);
+  }
+  template <class _Kp>
+    requires __is_transparent_v<_Compare>
+  _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const {
+    return __equal_range_impl(*this, __x);
+  }
+
+  friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_multiset& __x, const flat_multiset& __y) {
+    return ranges::equal(__x, __y);
+  }
+
+  friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_multiset& __x, const flat_multiset& __y) {
+    return std::lexicographical_compare_three_way(
+        __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
+  }
+
+  friend _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __x, flat_multiset& __y) noexcept { __x.swap(__y); }
+
+private:
+  template <bool _WasSorted, class... _Args>
+  _LIBCPP_HIDE_FROM_ABI void __append_sort_merge(_Args&&... __args) {
+    auto __on_failure    = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
+    size_type __old_size = size();
+    __flat_set_utils::__append(*this, std::forward<_Args>(__args)...);
+    if constexpr (!_WasSorted) {
+      ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_);
+    } else {
+      _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
+          ranges::is_sorted(__keys_ | ranges::views::drop(__old_size)), "Key container is not sorted");
+    }
+    ranges::inplace_merge(__keys_.begin(), __keys_.begin() + __old_size, __keys_.end(), __compare_);
+    __on_failure.__complete();
+  }
+
+  template <class _Kp>
+  _LIBCPP_HIDE_FROM_ABI iterator __emplace(_Kp&& __key) {
+    auto __it = upper_bound(__key);
+    return __flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key));
+  }
+
+  template <class _Kp>
+  _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint(const_iterator __hint, _Kp&& __key) {
+    auto __prev_larger  = __hint != cbegin() && __compare_(__key, *std::prev(__hint));
+    auto __next_smaller = __hint != cend() && __compare_(*__hint, __key);
+
+    if (!__prev_larger && !__next_smaller) [[likely]] {
+      // hint correct, just use exact hint iterator
+    } else if (__prev_larger && !__next_smaller) {
+      // the hint position is more to the right than the key should have been.
+      // we want to emplace the element to a position as right as possible
+      // e.g. Insert new element "2" in the following range
+      // 1, 1, 2, 2, 2, 3, 4, 6
+      //                   ^
+      //                   |
+      //                  hint
+      // We want to insert "2" after the last existing "2"
+      __hint = std::upper_bound(begin(), __hint, __key, __compare_);
+    } else {
+      _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multiset is not sorted");
+
+      // the hint position is more to the left than the key should have been.
+      // we want to emplace the element to a position as left as possible
+      //  1, 1, 2, 2, 2, 3, 4, 6
+      //  ^
+      //  |
+      // hint
+      // We want to insert "2" before the first existing "2"
+      __hint = std::lower_bound(__hint, end(), __key, __compare_);
+    }
+    return __flat_set_utils::__emplace_exact_pos(*this, __hint, std::forward<_Kp>(__key));
+  }
+
+  template <class _Self, class _Kp>
+  _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) {
+    auto __it   = __self.lower_bound(__key);
+    auto __last = __self.end();
+    if (__it == __last || __self.__compare_(__key, *__it)) {
+      return __last;
+    }
+    return __it;
+  }
+
+  template <class _Self, class _Kp>
+  _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
+    using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>;
+    auto [__key_first, __key_last] =
+        std::equal_range(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_);
+    return std::make_pair(__iter(__key_first), __iter(__key_last));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {
+    if constexpr (requires { __keys_.reserve(__size); }) {
+      __keys_.reserve(__size);
+    }
+  }
+
+  template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate>
+  friend typename flat_multiset<_Key2, _Compare2, _KeyContainer2>::size_type
+  erase_if(flat_multiset<_Key2, _Compare2, _KeyContainer2>&, _Predicate);
+
+  _KeyContainer __keys_;
+  _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
+
+  struct __key_equiv {
+    _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}
+    _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
+      return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
+    }
+    key_compare __comp_;
+  };
+};
+
+template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
+  requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+           is_invocable_v<const _Compare&,
+                          const typename _KeyContainer::value_type&,
+                          const typename _KeyContainer::value_type&>)
+flat_multiset(_KeyContainer, _Compare = _Compare())
+    -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
+
+template <class _KeyContainer, class _Allocator>
+  requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
+flat_multiset(_KeyContainer, _Allocator)
+    -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
+
+template <class _KeyContainer, class _Compare, class _Allocator>
+  requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+           uses_allocator_v<_KeyContainer, _Allocator> &&
+           is_invocable_v<const _Compare&,
+                          const typename _KeyContainer::value_type&,
+                          const typename _KeyContainer::value_type&>)
+flat_multiset(_KeyContainer, _Compare, _Allocator)
+    -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
+
+template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
+  requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+           is_invocable_v<const _Compare&,
+                          const typename _KeyContainer::value_type&,
+                          const typename _KeyContainer::value_type&>)
+flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare())
+    -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
+
+template <class _KeyContainer, class _Allocator>
+  requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
+flat_multiset(sorted_equivalent_t, _KeyContainer, _Allocator)
+    -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
+
+template <class _KeyContainer, class _Compare, class _Allocator>
+  requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+           uses_allocator_v<_KeyContainer, _Allocator> &&
+           is_invocable_v<const _Compare&,
+                          const typename _KeyContainer::value_type&,
+                          const typename _KeyContainer::value_type&>)
+flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Allocator)
+    -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
+
+template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
+  requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare())
+    -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>;
+
+template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
+  requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
+    -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>;
+
+template <ranges::input_range _Range,
+          class _Compare   = less<ranges::range_value_t<_Range>>,
+          class _Allocator = allocator<ranges::range_value_t<_Range>>,
+          class            = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
+flat_multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multiset<
+    ranges::range_value_t<_Range>,
+    _Compare,
+    vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>;
+
+template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
+flat_multiset(from_range_t, _Range&&, _Allocator) -> flat_multiset<
+    ranges::range_value_t<_Range>,
+    less<ranges::range_value_t<_Range>>,
+    vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>;
+
+template <class _Key, class _Compare = less<_Key>>
+  requires(!__is_allocator<_Compare>::value)
+flat_multiset(initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>;
+
+template <class _Key, class _Compare = less<_Key>>
+  requires(!__is_allocator<_Compare>::value)
+flat_multiset(sorted_equivalent_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>;
+
+template <class _Key, class _Compare, class _KeyContainer, class _Allocator>
+struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Allocator>
+    : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> > {};
+
+template <class _Key, class _Compare, class _KeyContainer, class _Predicate>
+_LIBCPP_HIDE_FROM_ABI typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type
+erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __flat_multiset, _Predicate __pred) {
+  auto __guard = std::__make_exception_guard([&] { __flat_multiset.clear(); });
+  auto __it =
+      std::remove_if(__flat_multiset.__keys_.begin(), __flat_multiset.__keys_.end(), [&](const auto& __e) -> bool {
+        return static_cast<bool>(__pred(__e));
+      });
+  auto __res = __flat_multiset.__keys_.end() - __it;
+  __flat_multiset.__keys_.erase(__it, __flat_multiset.__keys_.end());
+  __guard.__complete();
+  return __res;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FLAT_MAP_FLAT_MULTISET_H

diff  --git a/libcxx/include/__flat_set/flat_set.h b/libcxx/include/__flat_set/flat_set.h
index dca06c7236e73..a87496bb9916e 100644
--- a/libcxx/include/__flat_set/flat_set.h
+++ b/libcxx/include/__flat_set/flat_set.h
@@ -28,6 +28,7 @@
 #include <__cstddef/ptr
diff _t.h>
 #include <__flat_map/sorted_unique.h>
 #include <__flat_set/ra_iterator.h>
+#include <__flat_set/utils.h>
 #include <__functional/invoke.h>
 #include <__functional/is_transparent.h>
 #include <__functional/operations.h>
@@ -82,6 +83,8 @@ class flat_set {
   template <class, class, class>
   friend class flat_set;
 
+  friend __flat_set_utils;
+
   static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
   static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
 
@@ -619,31 +622,11 @@ class flat_set {
     __keys_.erase(__dup_start, __keys_.end());
   }
 
-  template <class _InputIterator>
-  _LIBCPP_HIDE_FROM_ABI void __append(_InputIterator __first, _InputIterator __last) {
-    __keys_.insert(__keys_.end(), std::move(__first), std::move(__last));
-  }
-
-  template <class _Range>
-  _LIBCPP_HIDE_FROM_ABI void __append(_Range&& __rng) {
-    if constexpr (requires { __keys_.insert_range(__keys_.end(), std::forward<_Range>(__rng)); }) {
-      // C++23 Sequence Container should have insert_range member function
-      // Note that not all Sequence Containers provide append_range.
-      __keys_.insert_range(__keys_.end(), std::forward<_Range>(__rng));
-    } else if constexpr (ranges::common_range<_Range>) {
-      __keys_.insert(__keys_.end(), ranges::begin(__rng), ranges::end(__rng));
-    } else {
-      for (auto&& __x : __rng) {
-        __keys_.insert(__keys_.end(), std::forward<decltype(__x)>(__x));
-      }
-    }
-  }
-
   template <bool _WasSorted, class... _Args>
   _LIBCPP_HIDE_FROM_ABI void __append_sort_merge_unique(_Args&&... __args) {
     auto __on_failure    = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
     size_type __old_size = size();
-    __append(std::forward<_Args>(__args)...);
+    __flat_set_utils::__append(*this, std::forward<_Args>(__args)...);
     if (size() != __old_size) {
       if constexpr (!_WasSorted) {
         ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_);
@@ -680,23 +663,11 @@ class flat_set {
     return std::make_pair(__iter(__it), __iter(std::next(__it)));
   }
 
-  template <class _KeyArg>
-  _LIBCPP_HIDE_FROM_ABI iterator __emplace_exact_pos(const_iterator __it, _KeyArg&& __key) {
-    auto __on_failure = std::__make_exception_guard([&]() noexcept {
-      if constexpr (!__container_traits<_KeyContainer>::__emplacement_has_strong_exception_safety_guarantee) {
-        clear() /* noexcept */;
-      }
-    });
-    auto __key_it     = __keys_.emplace(__it.__base(), std::forward<_KeyArg>(__key));
-    __on_failure.__complete();
-    return iterator(std::move(__key_it));
-  }
-
   template <class _Kp>
   _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace(_Kp&& __key) {
     auto __it = lower_bound(__key);
     if (__it == end() || __compare_(__key, *__it)) {
-      return pair<iterator, bool>(__emplace_exact_pos(__it, std::forward<_Kp>(__key)), true);
+      return pair<iterator, bool>(__flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key)), true);
     } else {
       return pair<iterator, bool>(std::move(__it), false);
     }
@@ -717,7 +688,7 @@ class flat_set {
   _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint(const_iterator __hint, _Kp&& __key) {
     if (__is_hint_correct(__hint, __key)) {
       if (__hint == cend() || __compare_(__key, *__hint)) {
-        return __emplace_exact_pos(__hint, std::forward<_Kp>(__key));
+        return __flat_set_utils::__emplace_exact_pos(*this, __hint, std::forward<_Kp>(__key));
       } else {
         // we already have an equal key
         return __hint;

diff  --git a/libcxx/include/__flat_set/utils.h b/libcxx/include/__flat_set/utils.h
new file mode 100644
index 0000000000000..ed3b4c48580fb
--- /dev/null
+++ b/libcxx/include/__flat_set/utils.h
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FLAT_SET_UTILS_H
+#define _LIBCPP___FLAT_SET_UTILS_H
+
+#include <__config>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__type_traits/container_traits.h>
+#include <__type_traits/decay.h>
+#include <__utility/exception_guard.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// These utilities are defined in a class instead of a namespace so that this class can be befriended more easily.
+struct __flat_set_utils {
+  // Emplace a key into a flat_{multi}set, at the exact position that
+  // __it point to, assuming that the key is not already present in the set.
+  // When an exception is thrown during the emplacement, the function will clear the set if the container does not
+  // have strong exception safety guarantee on emplacement.
+  template <class _Set, class _Iter, class _KeyArg>
+  _LIBCPP_HIDE_FROM_ABI static auto __emplace_exact_pos(_Set& __set, _Iter&& __iter, _KeyArg&& __key) {
+    using _KeyContainer = typename decay_t<_Set>::container_type;
+    auto __on_failure   = std::__make_exception_guard([&]() noexcept {
+      if constexpr (!__container_traits<_KeyContainer>::__emplacement_has_strong_exception_safety_guarantee) {
+        __set.clear() /* noexcept */;
+      }
+    });
+    auto __key_it       = __set.__keys_.emplace(__iter.__base(), std::forward<_KeyArg>(__key));
+    __on_failure.__complete();
+    return typename decay_t<_Set>::iterator(std::move(__key_it));
+  }
+
+  template <class _Set, class _InputIterator>
+  _LIBCPP_HIDE_FROM_ABI static void __append(_Set& __set, _InputIterator __first, _InputIterator __last) {
+    __set.__keys_.insert(__set.__keys_.end(), std::move(__first), std::move(__last));
+  }
+
+  template <class _Set, class _Range>
+  _LIBCPP_HIDE_FROM_ABI static void __append(_Set& __set, _Range&& __rng) {
+    if constexpr (requires { __set.__keys_.insert_range(__set.__keys_.end(), std::forward<_Range>(__rng)); }) {
+      // C++23 Sequence Container should have insert_range member function
+      // Note that not all Sequence Containers provide append_range.
+      __set.__keys_.insert_range(__set.__keys_.end(), std::forward<_Range>(__rng));
+    } else if constexpr (ranges::common_range<_Range>) {
+      __set.__keys_.insert(__set.__keys_.end(), ranges::begin(__rng), ranges::end(__rng));
+    } else {
+      for (auto&& __x : __rng) {
+        __set.__keys_.insert(__set.__keys_.end(), std::forward<decltype(__x)>(__x));
+      }
+    }
+  }
+};
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+_LIBCPP_POP_MACROS
+
+#endif // #define _LIBCPP___FLAT_SET_UTILS_H

diff  --git a/libcxx/include/flat_set b/libcxx/include/flat_set
index d03645fafafdb..ebbb3a0247f3e 100644
--- a/libcxx/include/flat_set
+++ b/libcxx/include/flat_set
@@ -31,6 +31,21 @@ namespace std {
   template<class Key, class Compare, class KeyContainer, class Predicate>
     typename flat_set<Key, Compare, KeyContainer>::size_type
       erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred);
+
+   // [flat.multiset], class template flat_multiset
+  template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
+    class flat_multiset;
+
+  struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; };
+  inline constexpr sorted_equivalent_t sorted_equivalent{};
+
+  template<class Key, class Compare, class KeyContainer, class Allocator>
+    struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>;
+
+  // [flat.multiset.erasure], erasure for flat_multiset
+  template<class Key, class Compare, class KeyContainer, class Predicate>
+    typename flat_multiset<Key, Compare, KeyContainer>::size_type
+      erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred);
 }
 */
 
@@ -40,7 +55,9 @@ namespace std {
 #  include <__config>
 
 #  if _LIBCPP_STD_VER >= 23
+#    include <__flat_map/sorted_equivalent.h>
 #    include <__flat_map/sorted_unique.h>
+#    include <__flat_set/flat_multiset.h>
 #    include <__flat_set/flat_set.h>
 #  endif
 

diff  --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 324931b1bb078..87164c74c9d99 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1305,13 +1305,16 @@ module std [system] {
   module flat_set {
     module flat_set                       {
       header "__flat_set/flat_set.h"
+      header "__flat_set/flat_multiset.h"
       export std.vector.vector
       export std.vector.fwd
     }
     module ra_iterator                    { header "__flat_set/ra_iterator.h" }
+    module utils                          { header "__flat_set/utils.h" }
 
     header "flat_set"
     export std.flat_map.sorted_unique
+    export std.flat_map.sorted_equivalent
     export *
   }
 

diff  --git a/libcxx/include/version b/libcxx/include/version
index 49102716c3605..0a19ff9ad8187 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -486,7 +486,7 @@ __cpp_lib_void_t                                        201411L <type_traits>
 # define __cpp_lib_containers_ranges                    202202L
 # define __cpp_lib_expected                             202211L
 # define __cpp_lib_flat_map                             202207L
-// # define __cpp_lib_flat_set                             202207L
+# define __cpp_lib_flat_set                             202207L
 # define __cpp_lib_format_ranges                        202207L
 // # define __cpp_lib_formatters                           202302L
 # define __cpp_lib_forward_like                         202207L

diff  --git a/libcxx/modules/std/flat_set.inc b/libcxx/modules/std/flat_set.inc
index 3f2c6e09a0ebe..51f39b75458b9 100644
--- a/libcxx/modules/std/flat_set.inc
+++ b/libcxx/modules/std/flat_set.inc
@@ -19,13 +19,11 @@ export namespace std {
 
   // [flat.set.erasure], erasure for flat_­set
   using std::erase_if;
-#endif // _LIBCPP_STD_VER >= 23
 
-#if 0
   // [flat.multiset], class template flat_­multiset
   using std::flat_multiset;
 
   using std::sorted_equivalent;
   using std::sorted_equivalent_t;
-#endif
+#endif // _LIBCPP_STD_VER >= 23
 } // namespace std

diff  --git a/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/assert.sorted_unique.pass.cpp b/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/assert.sorted_unique.pass.cpp
new file mode 100644
index 0000000000000..54b07baaff27a
--- /dev/null
+++ b/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/assert.sorted_unique.pass.cpp
@@ -0,0 +1,131 @@
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: has-unix-headers
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: libcpp-hardening-mode=none
+// REQUIRES: libcpp-hardening-mode=debug
+// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
+
+// <flat_set>
+
+// flat_multiset(container_type , const key_compare& __comp = key_compare())
+// flat_multiset(const container_type&  , const _Allocator& )
+// flat_multiset(const container_type&  , const key_compare&, const _Allocator& )
+// void replace(container_type&& )
+//
+
+#include <flat_set>
+#include <functional>
+#include <initializer_list>
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+  using M = std::flat_multiset<int>;
+
+  TEST_LIBCPP_ASSERT_FAILURE(([] { M m(std::sorted_equivalent, {4, 2, 3}); }()), "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] { M m(std::sorted_equivalent, {4, 2, 3}, std::less<int>{}); }()), "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        const std::vector keys{4, 2, 3};
+        const std::allocator<int> alloc{};
+        M m(std::sorted_equivalent, keys, alloc);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        const std::vector keys{4, 2, 3};
+        const std::allocator<int> alloc{};
+        const std::less<int> comp{};
+        M m(std::sorted_equivalent, keys, comp, alloc);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        const std::vector<int> v{4, 2, 3};
+        const std::less<int> comp{};
+        M m(std::sorted_equivalent, v.begin(), v.end(), comp);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        const std::vector<int> v{4, 2, 3};
+        const std::less<int> comp{};
+        const std::allocator<int> alloc{};
+        M m(std::sorted_equivalent, v.begin(), v.end(), comp, alloc);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        const std::vector<int> v{4, 2, 3};
+        const std::allocator<int> alloc{};
+        M m(std::sorted_equivalent, v.begin(), v.end(), alloc);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        std::initializer_list<int> v{4, 2, 3};
+        const std::less<int> comp{};
+        M m(std::sorted_equivalent, v, comp);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        std::initializer_list<int> v{4, 2, 3};
+        const std::less<int> comp{};
+        const std::allocator<int> alloc{};
+        M m(std::sorted_equivalent, v, comp, alloc);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        std::initializer_list<int> v{4, 2, 3};
+        const std::allocator<int> alloc{};
+        M m(std::sorted_equivalent, v, alloc);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        const std::vector<int> v{4, 2, 3};
+        M m;
+        m.insert(std::sorted_equivalent, v.begin(), v.end());
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        std::initializer_list<int> v{4, 2, 3};
+        M m;
+        m.insert(std::sorted_equivalent, v);
+      }()),
+      "Key container is not sorted");
+
+  TEST_LIBCPP_ASSERT_FAILURE(
+      ([] {
+        std::vector keys{2, 1, 3};
+        M m;
+        m.replace(std::move(keys));
+      }()),
+      "Key container is not sorted");
+
+  return 0;
+}

diff  --git a/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/iterator.compile.pass.cpp b/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/iterator.compile.pass.cpp
new file mode 100644
index 0000000000000..0954e42e52001
--- /dev/null
+++ b/libcxx/test/libcxx/containers/container.adaptors/flat.multiset/iterator.compile.pass.cpp
@@ -0,0 +1,42 @@
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// test that iterators from 
diff erent types of flat_multiset are not compatible
+
+#include <deque>
+#include <functional>
+#include <flat_set>
+#include <type_traits>
+
+using Iter1 = std::flat_multiset<int>::iterator;
+using Iter2 = std::flat_multiset<double>::iterator;
+using Iter3 = std::flat_multiset<int, std::greater<>>::iterator;
+using Iter4 = std::flat_multiset<int, std::less<int>, std::deque<int>>::iterator;
+
+static_assert(std::is_convertible_v<Iter1, Iter1>);
+static_assert(!std::is_convertible_v<Iter1, Iter2>);
+static_assert(!std::is_convertible_v<Iter1, Iter3>);
+static_assert(!std::is_convertible_v<Iter1, Iter4>);
+
+static_assert(!std::is_convertible_v<Iter2, Iter1>);
+static_assert(std::is_convertible_v<Iter2, Iter2>);
+static_assert(!std::is_convertible_v<Iter2, Iter3>);
+static_assert(!std::is_convertible_v<Iter2, Iter4>);
+
+static_assert(!std::is_convertible_v<Iter3, Iter1>);
+static_assert(!std::is_convertible_v<Iter3, Iter2>);
+static_assert(std::is_convertible_v<Iter3, Iter3>);
+static_assert(!std::is_convertible_v<Iter3, Iter4>);
+
+static_assert(!std::is_convertible_v<Iter4, Iter1>);
+static_assert(!std::is_convertible_v<Iter4, Iter2>);
+static_assert(!std::is_convertible_v<Iter4, Iter3>);
+static_assert(std::is_convertible_v<Iter4, Iter4>);

diff  --git a/libcxx/test/libcxx/diagnostics/flat_multiset.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/flat_multiset.nodiscard.verify.cpp
new file mode 100644
index 0000000000000..a271a293e94e7
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/flat_multiset.nodiscard.verify.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// [[nodiscard]] bool empty() const noexcept;
+
+#include <flat_set>
+
+void f() {
+  std::flat_multiset<int> c;
+  c.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.map/helpers.h b/libcxx/test/std/containers/container.adaptors/flat.map/helpers.h
index 8dbb85a6c0acf..b6b8fa061c840 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/helpers.h
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/helpers.h
@@ -15,6 +15,7 @@
 #include <vector>
 #include <flat_map>
 
+#include "../flat_helpers.h"
 #include "test_allocator.h"
 #include "test_macros.h"
 
@@ -30,150 +31,6 @@ void check_invariant(const std::flat_map<Args...>& m) {
   assert(std::adjacent_find(keys.begin(), keys.end(), key_equal) == keys.end());
 }
 
-struct StartsWith {
-  explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
-  StartsWith(const StartsWith&)     = delete;
-  void operator=(const StartsWith&) = delete;
-  struct Less {
-    using is_transparent = void;
-    bool operator()(const std::string& a, const std::string& b) const { return a < b; }
-    bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
-    bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
-    bool operator()(const StartsWith&, const StartsWith&) const {
-      assert(false); // should not be called
-      return false;
-    }
-  };
-
-private:
-  std::string lower_;
-  std::string upper_;
-};
-
-template <class T>
-struct CopyOnlyVector : std::vector<T> {
-  using std::vector<T>::vector;
-
-  CopyOnlyVector(const CopyOnlyVector&) = default;
-  CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
-  CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc) : CopyOnlyVector(other, alloc) {}
-
-  CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
-  CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
-};
-
-template <class T, bool ConvertibleToT = false>
-struct Transparent {
-  T t;
-
-  operator T() const
-    requires ConvertibleToT
-  {
-    return t;
-  }
-};
-
-template <class T>
-using ConvertibleTransparent = Transparent<T, true>;
-
-template <class T>
-using NonConvertibleTransparent = Transparent<T, false>;
-
-struct TransparentComparator {
-  using is_transparent = void;
-
-  bool* transparent_used  = nullptr;
-  TransparentComparator() = default;
-  TransparentComparator(bool& used) : transparent_used(&used) {}
-
-  template <class T, bool Convertible>
-  bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
-    if (transparent_used != nullptr) {
-      *transparent_used = true;
-    }
-    return t < transparent.t;
-  }
-
-  template <class T, bool Convertible>
-  bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
-    if (transparent_used != nullptr) {
-      *transparent_used = true;
-    }
-    return transparent.t < t;
-  }
-
-  template <class T>
-  bool operator()(const T& t1, const T& t2) const {
-    return t1 < t2;
-  }
-};
-
-struct NonTransparentComparator {
-  template <class T, bool Convertible>
-  bool operator()(const T&, const Transparent<T, Convertible>&) const;
-
-  template <class T, bool Convertible>
-  bool operator()(const Transparent<T, Convertible>&, const T&) const;
-
-  template <class T>
-  bool operator()(const T&, const T&) const;
-};
-
-struct NoDefaultCtr {
-  NoDefaultCtr() = delete;
-};
-
-#ifndef TEST_HAS_NO_EXCEPTIONS
-template <class T>
-struct EmplaceUnsafeContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  template <class... Args>
-  auto emplace(Args&&... args) -> decltype(std::declval<std::vector<T>>().emplace(std::forward<Args>(args)...)) {
-    if (this->size() > 1) {
-      auto it1 = this->begin();
-      auto it2 = it1 + 1;
-      // messing up the container
-      std::iter_swap(it1, it2);
-    }
-
-    throw 42;
-  }
-
-  template <class... Args>
-  auto insert(Args&&... args) -> decltype(std::declval<std::vector<T>>().insert(std::forward<Args>(args)...)) {
-    if (this->size() > 1) {
-      auto it1 = this->begin();
-      auto it2 = it1 + 1;
-      // messing up the container
-      std::iter_swap(it1, it2);
-    }
-
-    throw 42;
-  }
-};
-
-template <class T>
-struct ThrowOnEraseContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  template <class... Args>
-  auto erase(Args&&... args) -> decltype(std::declval<std::vector<T>>().erase(std::forward<Args>(args)...)) {
-    throw 42;
-  }
-};
-
-template <class T>
-struct ThrowOnMoveContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  ThrowOnMoveContainer(ThrowOnMoveContainer&&) { throw 42; }
-
-  ThrowOnMoveContainer& operator=(ThrowOnMoveContainer&&) { throw 42; }
-};
-
-#endif
-
 template <class F>
 void test_emplace_exception_guarantee([[maybe_unused]] F&& emplace_function) {
 #ifndef TEST_HAS_NO_EXCEPTIONS
@@ -363,32 +220,5 @@ void test_erase_exception_guarantee([[maybe_unused]] F&& erase_function) {
   }
 #endif
 }
-class Moveable {
-  int int_;
-  double double_;
-
-public:
-  Moveable() : int_(0), double_(0) {}
-  Moveable(int i, double d) : int_(i), double_(d) {}
-  Moveable(Moveable&& x) : int_(x.int_), double_(x.double_) {
-    x.int_    = -1;
-    x.double_ = -1;
-  }
-  Moveable& operator=(Moveable&& x) {
-    int_      = x.int_;
-    x.int_    = -1;
-    double_   = x.double_;
-    x.double_ = -1;
-    return *this;
-  }
-
-  Moveable(const Moveable&)            = delete;
-  Moveable& operator=(const Moveable&) = delete;
-  bool operator==(const Moveable& x) const { return int_ == x.int_ && double_ == x.double_; }
-  bool operator<(const Moveable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
-
-  int get() const { return int_; }
-  bool moved() const { return int_ == -1; }
-};
 
 #endif // SUPPORT_FLAT_MAP_HELPERS_H

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/helpers.h b/libcxx/test/std/containers/container.adaptors/flat.multimap/helpers.h
index 252e2454d497c..68d7f67a6669f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/helpers.h
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/helpers.h
@@ -15,6 +15,7 @@
 #include <vector>
 #include <flat_map>
 
+#include "../flat_helpers.h"
 #include "test_allocator.h"
 #include "test_macros.h"
 
@@ -25,150 +26,6 @@ void check_invariant(const std::flat_multimap<Args...>& m) {
   assert(std::is_sorted(keys.begin(), keys.end(), m.key_comp()));
 }
 
-struct StartsWith {
-  explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
-  StartsWith(const StartsWith&)     = delete;
-  void operator=(const StartsWith&) = delete;
-  struct Less {
-    using is_transparent = void;
-    bool operator()(const std::string& a, const std::string& b) const { return a < b; }
-    bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
-    bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
-    bool operator()(const StartsWith&, const StartsWith&) const {
-      assert(false); // should not be called
-      return false;
-    }
-  };
-
-private:
-  std::string lower_;
-  std::string upper_;
-};
-
-template <class T>
-struct CopyOnlyVector : std::vector<T> {
-  using std::vector<T>::vector;
-
-  CopyOnlyVector(const CopyOnlyVector&) = default;
-  CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
-  CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc) : CopyOnlyVector(other, alloc) {}
-
-  CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
-  CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
-};
-
-template <class T, bool ConvertibleToT = false>
-struct Transparent {
-  T t;
-
-  operator T() const
-    requires ConvertibleToT
-  {
-    return t;
-  }
-};
-
-template <class T>
-using ConvertibleTransparent = Transparent<T, true>;
-
-template <class T>
-using NonConvertibleTransparent = Transparent<T, false>;
-
-struct TransparentComparator {
-  using is_transparent = void;
-
-  bool* transparent_used  = nullptr;
-  TransparentComparator() = default;
-  TransparentComparator(bool& used) : transparent_used(&used) {}
-
-  template <class T, bool Convertible>
-  bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
-    if (transparent_used != nullptr) {
-      *transparent_used = true;
-    }
-    return t < transparent.t;
-  }
-
-  template <class T, bool Convertible>
-  bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
-    if (transparent_used != nullptr) {
-      *transparent_used = true;
-    }
-    return transparent.t < t;
-  }
-
-  template <class T>
-  bool operator()(const T& t1, const T& t2) const {
-    return t1 < t2;
-  }
-};
-
-struct NonTransparentComparator {
-  template <class T, bool Convertible>
-  bool operator()(const T&, const Transparent<T, Convertible>&) const;
-
-  template <class T, bool Convertible>
-  bool operator()(const Transparent<T, Convertible>&, const T&) const;
-
-  template <class T>
-  bool operator()(const T&, const T&) const;
-};
-
-struct NoDefaultCtr {
-  NoDefaultCtr() = delete;
-};
-
-#ifndef TEST_HAS_NO_EXCEPTIONS
-template <class T>
-struct EmplaceUnsafeContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  template <class... Args>
-  auto emplace(Args&&... args) -> decltype(std::declval<std::vector<T>>().emplace(std::forward<Args>(args)...)) {
-    if (this->size() > 1) {
-      auto it1 = this->begin();
-      auto it2 = it1 + 1;
-      // messing up the container
-      std::iter_swap(it1, it2);
-    }
-
-    throw 42;
-  }
-
-  template <class... Args>
-  auto insert(Args&&... args) -> decltype(std::declval<std::vector<T>>().insert(std::forward<Args>(args)...)) {
-    if (this->size() > 1) {
-      auto it1 = this->begin();
-      auto it2 = it1 + 1;
-      // messing up the container
-      std::iter_swap(it1, it2);
-    }
-
-    throw 42;
-  }
-};
-
-template <class T>
-struct ThrowOnEraseContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  template <class... Args>
-  auto erase(Args&&... args) -> decltype(std::declval<std::vector<T>>().erase(std::forward<Args>(args)...)) {
-    throw 42;
-  }
-};
-
-template <class T>
-struct ThrowOnMoveContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  ThrowOnMoveContainer(ThrowOnMoveContainer&&) { throw 42; }
-
-  ThrowOnMoveContainer& operator=(ThrowOnMoveContainer&&) { throw 42; }
-};
-
-#endif
-
 template <class F>
 void test_emplace_exception_guarantee([[maybe_unused]] F&& emplace_function) {
 #ifndef TEST_HAS_NO_EXCEPTIONS
@@ -358,32 +215,5 @@ void test_erase_exception_guarantee([[maybe_unused]] F&& erase_function) {
   }
 #endif
 }
-class Moveable {
-  int int_;
-  double double_;
-
-public:
-  Moveable() : int_(0), double_(0) {}
-  Moveable(int i, double d) : int_(i), double_(d) {}
-  Moveable(Moveable&& x) : int_(x.int_), double_(x.double_) {
-    x.int_    = -1;
-    x.double_ = -1;
-  }
-  Moveable& operator=(Moveable&& x) {
-    int_      = x.int_;
-    x.int_    = -1;
-    double_   = x.double_;
-    x.double_ = -1;
-    return *this;
-  }
-
-  Moveable(const Moveable&)            = delete;
-  Moveable& operator=(const Moveable&) = delete;
-  bool operator==(const Moveable& x) const { return int_ == x.int_ && double_ == x.double_; }
-  bool operator<(const Moveable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
-
-  int get() const { return int_; }
-  bool moved() const { return int_ == -1; }
-};
 
 #endif // SUPPORT_FLAT_MULTIMAP_HELPERS_H

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/empty.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/empty.pass.cpp
new file mode 100644
index 0000000000000..52f77438df2ce
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/empty.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// [[nodiscard]] bool empty() const noexcept;
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+#include <functional>
+#include <utility>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<int>, KeyContainer>;
+  M m;
+  ASSERT_SAME_TYPE(decltype(m.empty()), bool);
+  ASSERT_NOEXCEPT(m.empty());
+  assert(m.empty());
+  assert(std::as_const(m).empty());
+  m = {1};
+  assert(!m.empty());
+  m.clear();
+  assert(m.empty());
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/max_size.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/max_size.pass.cpp
new file mode 100644
index 0000000000000..4e3d1414b28af
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/max_size.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// size_type max_size() const noexcept;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <limits>
+#include <type_traits>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "test_allocator.h"
+#include "test_macros.h"
+
+void test() {
+  {
+    using A1 = limited_allocator<int, 10>;
+    using C  = std::flat_multiset<int, std::less<int>, std::vector<int, A1>>;
+    ASSERT_SAME_TYPE(C::
diff erence_type, std::ptr
diff _t);
+    ASSERT_SAME_TYPE(C::size_type, std::size_t);
+    const C c;
+    ASSERT_NOEXCEPT(c.max_size());
+    ASSERT_SAME_TYPE(decltype(c.max_size()), C::size_type);
+    assert(c.max_size() <= 10);
+    LIBCPP_ASSERT(c.max_size() == 10);
+  }
+  {
+    using A = limited_allocator<int, (size_t)-1>;
+    using C = std::flat_multiset<int, std::less<int>, std::vector<int, A>>;
+    ASSERT_SAME_TYPE(C::
diff erence_type, std::ptr
diff _t);
+    ASSERT_SAME_TYPE(C::size_type, std::size_t);
+    const C::size_type max_dist = static_cast<C::size_type>(std::numeric_limits<C::
diff erence_type>::max());
+    const C c;
+    ASSERT_NOEXCEPT(c.max_size());
+    ASSERT_SAME_TYPE(decltype(c.max_size()), C::size_type);
+    assert(c.max_size() <= max_dist);
+    LIBCPP_ASSERT(c.max_size() == max_dist);
+  }
+  {
+    typedef std::flat_multiset<char> C;
+    ASSERT_SAME_TYPE(C::
diff erence_type, std::ptr
diff _t);
+    ASSERT_SAME_TYPE(C::size_type, std::size_t);
+    const C::size_type max_dist = static_cast<C::size_type>(std::numeric_limits<C::
diff erence_type>::max());
+    const C c;
+    ASSERT_NOEXCEPT(c.max_size());
+    ASSERT_SAME_TYPE(decltype(c.max_size()), C::size_type);
+    assert(c.max_size() <= max_dist);
+    assert(c.max_size() <= alloc_max_size(std::allocator<char>()));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/size.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/size.pass.cpp
new file mode 100644
index 0000000000000..4aff08b8127b6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.capacity/size.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// size_type size() const noexcept;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using M = std::flat_multiset<int, std::less<int>, KeyContainer>;
+  using S = typename M::size_type;
+  {
+    const M m = {1, 1, 4, 5, 5};
+    ASSERT_SAME_TYPE(decltype(m.size()), S);
+    ASSERT_NOEXCEPT(m.size());
+    assert(m.size() == 5);
+  }
+  {
+    const M m = {1};
+    ASSERT_SAME_TYPE(decltype(m.size()), S);
+    ASSERT_NOEXCEPT(m.size());
+    assert(m.size() == 1);
+  }
+  {
+    const M m;
+    ASSERT_SAME_TYPE(decltype(m.size()), S);
+    ASSERT_NOEXCEPT(m.size());
+    assert(m.size() == 0);
+  }
+  {
+    M m;
+    S s = 500000;
+    for (std::size_t i = 0u; i < s; ++i) {
+      m.emplace(i);
+      m.emplace(i);
+    }
+    ASSERT_SAME_TYPE(decltype(m.size()), S);
+    ASSERT_NOEXCEPT(m.size());
+    assert(m.size() == 2 * s);
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/alloc.pass.cpp
new file mode 100644
index 0000000000000..4fffcb304d20a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/alloc.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class Allocator>
+//   explicit flat_multiset(const Allocator& a);
+
+#include <cassert>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    static_assert(std::is_constructible_v<M1, const A1&>);
+    static_assert(std::is_constructible_v<M2, const A2&>);
+    static_assert(!std::is_constructible_v<M1, const A2&>);
+    static_assert(!std::is_constructible_v<M2, const A1&>);
+  }
+  {
+    // explicit
+    using M = std::flat_multiset<int, std::less<int>, std::vector<int, test_allocator<int>>>;
+
+    static_assert(std::is_constructible_v<M, test_allocator<int>>);
+    static_assert(!std::is_convertible_v<test_allocator<int>, M>);
+  }
+  {
+    using A = test_allocator<short>;
+    using M = std::flat_multiset<int, std::less<int>, std::vector<int, test_allocator<int>>>;
+    M m(A(0, 5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(std::move(m).extract().get_allocator().get_id() == 5);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..ae81ab044932d
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset& operator=(initializer_list<value_type> il);
+
+#include <algorithm>
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <ranges>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+
+template <class KeyContainer>
+void test() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  {
+    M m = {8, 10};
+    assert(m.size() == 2);
+    m              = {3, 1, 2, 2, 3, 4, 3, 5, 6, 5};
+    int expected[] = {1, 2, 2, 3, 3, 3, 4, 5, 5, 6};
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    M m = {10, 8};
+    assert(m.size() == 2);
+    m                 = {3};
+    double expected[] = {3};
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    // was empty
+    M m;
+    assert(m.size() == 0);
+    m              = {3, 1, 2, 2, 3, 4, 3, 5, 6, 5};
+    int expected[] = {1, 2, 2, 3, 3, 3, 4, 5, 5, 6};
+    assert(std::ranges::equal(m, expected));
+  }
+}
+
+void test() {
+  test<std::vector<int>>();
+  test<std::vector<double>>();
+  test<std::deque<int>>();
+  test<MinSequenceContainer<int>>();
+  test<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/compare.pass.cpp
new file mode 100644
index 0000000000000..6b68589e6814f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/compare.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// explicit flat_multiset(const key_compare& comp);
+// template <class Alloc>
+//   flat_multiset(const key_compare& comp, const Alloc& a);
+
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <type_traits>
+#include <vector>
+
+#include "test_macros.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    static_assert(std::is_constructible_v<M1, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, const C&, const A1&>);
+  }
+  {
+    using C = test_less<int>;
+    auto m  = std::flat_multiset<int, C>(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+  }
+  {
+    // The one-argument ctor is explicit.
+    using C = test_less<int>;
+    static_assert(std::is_constructible_v<std::flat_multiset<int, C>, C>);
+    static_assert(!std::is_convertible_v<C, std::flat_multiset<int, C>>);
+
+    static_assert(std::is_constructible_v<std::flat_multiset<int>, std::less<int>>);
+    static_assert(!std::is_convertible_v<std::less<int>, std::flat_multiset<int>>);
+  }
+  {
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    auto m   = std::flat_multiset<int, C, std::vector<int, A1>>(C(4), A1(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // explicit(false)
+    using C                                           = test_less<int>;
+    using A1                                          = test_allocator<int>;
+    std::flat_multiset<int, C, std::deque<int, A1>> m = {C(4), A1(5)};
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/containers.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/containers.pass.cpp
new file mode 100644
index 0000000000000..78eac420a8f22
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/containers.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// explicit flat_multiset(container_type key_cont, const key_compare& comp = key_compare());
+// template<class Allocator>
+//   flat_multiset(const container_type& key_cont, const Allocator& a);
+// template<class Alloc>
+//   flat_multiset(const container_type& key_cont, const key_compare& comp, const Alloc& a);
+
+#include <algorithm>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "min_allocator.h"
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+
+template <class T>
+void conversion_test(T);
+
+template <class T, class... Args>
+concept ImplicitlyConstructible = requires(Args&&... args) { conversion_test<T>({std::forward<Args>(args)...}); };
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    static_assert(std::is_constructible_v<M1, const V1&, const A1&>);
+    static_assert(std::is_constructible_v<M2, const V2&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, const V1&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, const V2&, const A1&>);
+
+    static_assert(std::is_constructible_v<M1, const V1&, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, const V2&, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, const V1&, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, const V2&, const C&, const A1&>);
+  }
+  {
+    // flat_multiset(container_type)
+    using M             = std::flat_multiset<int>;
+    std::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+    auto m              = M(ks);
+    int expected[]      = {1, 1, 1, 2, 2, 2, 3, 3, 3};
+    assert(std::ranges::equal(m, expected));
+
+    // explicit(false)
+    static_assert(std::is_constructible_v<M, const std::vector<int>&>);
+    static_assert(!ImplicitlyConstructible<M, const std::vector<int>&>);
+
+    m = M(std::move(ks));
+    assert(ks.empty()); // it was moved-from
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    // flat_multiset(container_type)
+    // move-only
+    int expected[] = {3, 3, 2, 1};
+    using Ks       = std::deque<MoveOnly, min_allocator<MoveOnly>>;
+    using M        = std::flat_multiset<MoveOnly, std::greater<MoveOnly>, Ks>;
+    Ks ks;
+    ks.push_back(1);
+    ks.push_back(3);
+    ks.push_back(3);
+    ks.push_back(2);
+    auto m = M(std::move(ks));
+    assert(ks.empty()); // it was moved-from
+    assert(std::ranges::equal(m, expected, std::equal_to<>()));
+  }
+  {
+    // flat_multiset(container_type)
+    // container's allocators are used
+    using A = test_allocator<int>;
+    using M = std::flat_multiset<int, std::less<int>, std::deque<int, A>>;
+    auto ks = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+    auto m  = M(std::move(ks));
+    assert(ks.empty()); // it was moved-from
+    assert((m == M{1, 1, 1, 2, 2, 2, 3, 3, 3}));
+    auto keys = std::move(m).extract();
+    assert(keys.get_allocator() == A(5));
+  }
+  {
+    // flat_multiset(container_type, key_compare)
+    using C             = test_less<int>;
+    using M             = std::flat_multiset<int, C>;
+    std::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+    auto m              = M(ks, C(4));
+    assert(std::ranges::equal(m, std::vector<int>{1, 1, 1, 2, 2, 2, 3, 3, 3}));
+    assert(m.key_comp() == C(4));
+
+    // explicit
+    static_assert(std::is_constructible_v<M, const std::vector<int>&, const C&>);
+    static_assert(!ImplicitlyConstructible<M, const std::vector<int>&, const C&>);
+  }
+  {
+    // flat_multiset(container_type , const Allocator&)
+    using A = test_allocator<int>;
+    using M = std::flat_multiset<int, std::less<int>, std::deque<int, A>>;
+    auto ks = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+    auto m  = M(ks, A(4)); // replaces the allocators
+    assert(!ks.empty());   // it was an lvalue above
+    assert((m == M{1, 1, 1, 2, 2, 2, 3, 3, 3}));
+    auto keys = M(m).extract();
+    assert(keys.get_allocator() == A(4));
+
+    // explicit(false)
+    static_assert(ImplicitlyConstructible<M, const std::deque<int, A>&, const A&>);
+    M m2 = {ks, A(4)};   // implicit ctor
+    assert(!ks.empty()); // it was an lvalue above
+    assert(m2 == m);
+    auto keys2 = std::move(m).extract();
+    assert(keys2.get_allocator() == A(4));
+  }
+  {
+    // flat_multiset(container_type , const Allocator&)
+    using C                = test_less<int>;
+    using A                = test_allocator<int>;
+    using M                = std::flat_multiset<int, C, std::vector<int, A>>;
+    std::vector<int, A> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+    auto m                 = M(ks, C(4), A(5));
+    assert(std::ranges::equal(m, std::vector<int, A>{1, 1, 1, 2, 2, 2, 3, 3, 3}));
+    assert(m.key_comp() == C(4));
+    auto m_copy = m;
+    auto keys   = std::move(m_copy).extract();
+    assert(keys.get_allocator() == A(5));
+
+    // explicit(false)
+    static_assert(ImplicitlyConstructible<M, const std::vector<int, A>&, const A&>);
+    M m2 = {ks, C(4), A(5)};
+    assert(m2 == m);
+    assert(m2.key_comp() == C(4));
+    keys = std::move(m2).extract();
+    assert(keys.get_allocator() == A(5));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy.pass.cpp
new file mode 100644
index 0000000000000..b4f7220e1bac7
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset(const flat_multiset& m);
+
+#include <algorithm>
+#include <cassert>
+#include <flat_set>
+#include <vector>
+
+#include "test_macros.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+void test() {
+  {
+    using C = test_less<int>;
+    std::vector<int, test_allocator<int>> ks({1, 3, 5, 3, 1}, test_allocator<int>(6));
+    const int expected[] = {1, 1, 3, 3, 5};
+    using M              = std::flat_multiset<int, C, decltype(ks)>;
+    auto mo              = M(ks, C(5));
+    auto m               = mo;
+
+    assert(m.key_comp() == C(5));
+    assert(std::ranges::equal(m, expected));
+    auto keys = std::move(m).extract();
+    assert(keys.get_allocator() == test_allocator<int>(6));
+
+    // mo is unchanged
+    assert(mo.key_comp() == C(5));
+    assert(std::ranges::equal(mo, expected));
+    auto keys2 = std::move(mo).extract();
+    assert(keys2.get_allocator() == test_allocator<int>(6));
+  }
+  {
+    using C              = test_less<int>;
+    using Ks             = std::vector<int, other_allocator<int>>;
+    auto ks              = Ks({1, 3, 5, 3, 1}, other_allocator<int>(6));
+    const int expected[] = {1, 1, 3, 3, 5};
+    using M              = std::flat_multiset<int, C, Ks>;
+    auto mo              = M(Ks(ks, other_allocator<int>(6)), C(5));
+    auto m               = mo;
+
+    assert(m.key_comp() == C(5));
+    assert(std::ranges::equal(m, expected));
+    auto keys = std::move(m).extract();
+    assert(keys.get_allocator() == other_allocator<int>(-2));
+
+    // mo is unchanged
+    assert(mo.key_comp() == C(5));
+    assert(std::ranges::equal(mo, expected));
+    auto keys2 = std::move(mo).extract();
+    assert(keys2.get_allocator() == other_allocator<int>(6));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000000000..ec8ad824ea14b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_alloc.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset(const flat_multiset&, const allocator_type&);
+
+#include <algorithm>
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "test_macros.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    static_assert(std::is_constructible_v<M1, const M1&, const A1&>);
+    static_assert(std::is_constructible_v<M2, const M2&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, const M1&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, const M2&, const A1&>);
+  }
+  {
+    using C = test_less<int>;
+    std::vector<int, test_allocator<int>> ks({1, 3, 5, 5}, test_allocator<int>(6));
+    using M = std::flat_multiset<int, C, decltype(ks)>;
+    auto mo = M(ks, C(5));
+    auto m  = M(mo, test_allocator<int>(3));
+
+    assert(m.key_comp() == C(5));
+    assert(std::ranges::equal(m, ks));
+    auto keys = std::move(m).extract();
+    assert(keys.get_allocator() == test_allocator<int>(3));
+
+    // mo is unchanged
+    assert(mo.key_comp() == C(5));
+    assert(std::ranges::equal(mo, ks));
+    auto keys2 = std::move(mo).extract();
+    assert(keys2.get_allocator() == test_allocator<int>(6));
+  }
+}
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000000000..2b6176ac915a7
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_assign.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset& operator=(const flat_multiset& m);
+
+#include <algorithm>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "operator_hijacker.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+void test() {
+  {
+    // test_allocator is not propagated
+    using C = test_less<int>;
+    std::vector<int, test_allocator<int>> ks({1, 3, 5, 5}, test_allocator<int>(6));
+    using M = std::flat_multiset<int, C, decltype(ks)>;
+    auto mo = M(ks, C(5));
+    auto m  = M({{3, 4, 5, 4}}, C(3), test_allocator<int>(2));
+    m       = mo;
+
+    assert(m.key_comp() == C(5));
+    assert(std::ranges::equal(m, ks));
+    auto keys = std::move(m).extract();
+    assert(keys.get_allocator() == test_allocator<int>(2));
+
+    // mo is unchanged
+    assert(mo.key_comp() == C(5));
+    assert(std::ranges::equal(mo, ks));
+    auto keys2 = std::move(mo).extract();
+    assert(keys2.get_allocator() == test_allocator<int>(6));
+  }
+  {
+    // other_allocator is propagated
+    using C              = test_less<int>;
+    using Ks             = std::vector<int, other_allocator<int>>;
+    auto ks              = Ks({1, 3, 5, 3}, other_allocator<int>(6));
+    const int expected[] = {1, 3, 3, 5};
+    using M              = std::flat_multiset<int, C, Ks>;
+    auto mo              = M(Ks(ks, other_allocator<int>(6)), C(5));
+    auto m               = M({3, 4, 5}, C(3), other_allocator<int>(2));
+    m                    = mo;
+
+    assert(m.key_comp() == C(5));
+    assert(std::ranges::equal(m, expected));
+    auto keys = std::move(m).extract();
+    assert(keys.get_allocator() == other_allocator<int>(6));
+
+    // mo is unchanged
+    assert(mo.key_comp() == C(5));
+    assert(std::ranges::equal(mo, expected));
+    auto keys2 = std::move(mo).extract();
+    assert(keys2.get_allocator() == other_allocator<int>(6));
+  }
+  {
+    // comparator is copied and invariant is preserved
+    using M = std::flat_multiset<int, std::function<bool(int, int)>>;
+    M mo    = M({1, 2}, std::less<int>());
+    M m     = M({1, 2}, std::greater<int>());
+    assert(m.key_comp()(2, 1) == true);
+    assert(m != mo);
+    m = mo;
+    assert(m.key_comp()(2, 1) == false);
+    assert(m == mo);
+  }
+  {
+    // self-assignment
+    using M = std::flat_multiset<int>;
+    M m     = {{1, 2}};
+    m       = std::as_const(m);
+    assert((m == M{{1, 2}}));
+  }
+  {
+    // was empty
+    using M = std::flat_multiset<int>;
+    M m;
+    assert(m.size() == 0);
+    m              = {3, 1, 2, 2, 3, 4, 3, 5, 6, 5};
+    int expected[] = {1, 2, 2, 3, 3, 3, 4, 5, 5, 6};
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    // Validate whether the container can be copy-assigned (move-assigned, swapped)
+    // with an ADL-hijacking operator&
+    std::flat_multiset<operator_hijacker> so;
+    std::flat_multiset<operator_hijacker> s;
+    s = so;
+    s = std::move(so);
+    swap(s, so);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.compile.pass.cpp
new file mode 100644
index 0000000000000..f26c90bacdda7
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.compile.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// Test CTAD on cases where deduction should fail.
+
+#include <flat_set>
+#include <functional>
+#include <memory>
+#include <utility>
+#include <vector>
+
+struct NotAnAllocator {
+  friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
+};
+
+template <class... Args>
+concept CanDeductFlatMultiSet = requires { std::flat_multiset(std::declval<Args>()...); };
+
+static_assert(CanDeductFlatMultiSet<std::vector<int>>);
+
+// cannot deduce Key and T from nothing
+static_assert(!CanDeductFlatMultiSet<>);
+
+// cannot deduce Key and T from just (Compare)
+static_assert(!CanDeductFlatMultiSet<std::less<int>>);
+
+// cannot deduce Key and T from just (Compare, Allocator)
+static_assert(!CanDeductFlatMultiSet<std::less<int>, std::allocator<int>>);
+
+// cannot deduce Key and T from just (Allocator)
+static_assert(!CanDeductFlatMultiSet<std::allocator<int>>);
+
+// cannot convert from some arbitrary unrelated type
+static_assert(!CanDeductFlatMultiSet<NotAnAllocator>);

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.pass.cpp
new file mode 100644
index 0000000000000..7f611776e85c3
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct.pass.cpp
@@ -0,0 +1,410 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+#include <algorithm>
+#include <cassert>
+#include <climits>
+#include <deque>
+#include <initializer_list>
+#include <list>
+#include <flat_set>
+#include <functional>
+#include <ranges>
+#include <type_traits>
+#include <utility>
+#include <vector>
+
+#include "deduction_guides_sfinae_checks.h"
+#include "test_allocator.h"
+
+void test() {
+  {
+    // Deduction guide generated from
+    // flat_multiset(const flat_multiset&)
+    std::flat_multiset<long> source = {1, 2, 2};
+    std::flat_multiset s(source);
+    ASSERT_SAME_TYPE(decltype(s), decltype(source));
+    assert(s == source);
+  }
+  {
+    // Deduction guide generated from
+    // flat_multiset(const flat_multiset&)
+    // braces instead of parens
+    std::flat_multiset<short, std::greater<short>> source = {1, 2, 2};
+    std::flat_multiset s{source};
+    ASSERT_SAME_TYPE(decltype(s), decltype(source));
+    assert(s == source);
+  }
+  {
+    // Deduction guide generated from
+    // flat_set(const flat_set&, const Allocator&)
+    std::flat_multiset<long, std::greater<long>> source = {1, 2, 2};
+    std::flat_multiset s(source, std::allocator<int>());
+    ASSERT_SAME_TYPE(decltype(s), decltype(source));
+    assert(s == source);
+  }
+  {
+    std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
+    std::deque<int, test_allocator<int>> sorted_ks({1, 1, 2, 3, INT_MAX}, test_allocator<int>(0, 42));
+    int expected[] = {1, 1, 2, 3, INT_MAX};
+    {
+      // template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
+      // flat_multiset(KeyContainer, Compare = Compare())
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+      std::flat_multiset s(ks);
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 42);
+    }
+    {
+      // template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
+      // flat_multiset(sorted_equivalent_t, KeyContainer, Compare = Compare())
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+      std::flat_multiset s(std::sorted_equivalent, sorted_ks);
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 42);
+    }
+    {
+      // template<class KeyContainer, class Allocator>
+      // flat_multiset(KeyContainer, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type,
+      //                    less<typename KeyContainer::value_type>, KeyContainer>;
+      std::flat_multiset s(ks, test_allocator<long>(0, 44));
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 44);
+    }
+    {
+      // template<class KeyContainer, class Allocator>
+      // flat_multiset(sorted_equivalent_t, KeyContainer, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type,
+      //                    less<typename KeyContainer::value_type>, KeyContainer>;
+      std::flat_multiset s(std::sorted_equivalent, sorted_ks, test_allocator<long>(0, 44));
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 44);
+    }
+  }
+  {
+    std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
+    std::deque<int, test_allocator<int>> sorted_ks({INT_MAX, 3, 2, 1, 1}, test_allocator<int>(0, 42));
+    int expected[] = {INT_MAX, 3, 2, 1, 1};
+    {
+      // template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
+      // flat_multiset(KeyContainer, Compare = Compare())
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+      std::flat_multiset s(ks, std::greater<int>());
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 42);
+    }
+    {
+      // template<class KeyContainer, class Compare = less<typename KeyContainer::value_type>>
+      // flat_multiset(sorted_equivalent_t, KeyContainer, Compare = Compare())
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+
+      std::flat_multiset s(std::sorted_equivalent, sorted_ks, std::greater<int>());
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 42);
+    }
+    {
+      // template<class KeyContainer, class Compare, class Allocator>
+      // flat_multiset(KeyContainer, Compare, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+      std::flat_multiset s(ks, std::greater<int>(), test_allocator<long>(0, 44));
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 44);
+    }
+    {
+      // template<class KeyContainer, class Compare, class Allocator>
+      // flat_multiset(sorted_equivalent_t, KeyContainer, Compare, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+      std::flat_multiset s(std::sorted_equivalent, sorted_ks, std::greater<int>(), test_allocator<long>(0, 44));
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>, decltype(ks)>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 44);
+    }
+  }
+
+  {
+    int arr[]               = {1, 2, 1, INT_MAX, 3};
+    int sorted_arr[]        = {1, 1, 2, 3, INT_MAX};
+    const int arrc[]        = {1, 2, 1, INT_MAX, 3};
+    const int sorted_arrc[] = {1, 1, 2, 3, INT_MAX};
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      std::flat_multiset m(std::begin(arr), std::end(arr));
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // const
+      std::flat_multiset m(std::begin(arrc), std::end(arrc));
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      std::flat_multiset m(std::sorted_equivalent, std::begin(sorted_arr), std::end(sorted_arr));
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // const
+      std::flat_multiset m(std::sorted_equivalent, std::begin(sorted_arrc), std::end(sorted_arrc));
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // flat_multiset iterator
+      std::flat_multiset<int> mo;
+      std::flat_multiset m(mo.begin(), mo.end());
+      ASSERT_SAME_TYPE(decltype(m), decltype(mo));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // flat_multiset const_iterator
+      std::flat_multiset<int> mo;
+      std::flat_multiset m(mo.cbegin(), mo.cend());
+      ASSERT_SAME_TYPE(decltype(m), decltype(mo));
+    }
+    {
+      // This does not deduce to flat_multiset(InputIterator, InputIterator)
+      // But deduces to flat_multiset(initializer_list<int*>)
+      int source[3]        = {1, 2, 3};
+      std::flat_multiset s = {source, source + 3};
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int*>);
+      assert(s.size() == 2);
+    }
+    {
+      // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator)
+      // braces
+      int source[3] = {1, 2, 3};
+      std::flat_multiset s{std::sorted_equivalent, source, source + 3};
+      static_assert(std::is_same_v<decltype(s), std::flat_multiset<int>>);
+      assert(s.size() == 3);
+    }
+  }
+
+  {
+    int arr[]               = {1, 2, 1, INT_MAX, 3};
+    int sorted_arr[]        = {INT_MAX, 3, 2, 1, 1};
+    const int arrc[]        = {1, 2, 1, INT_MAX, 3};
+    const int sorted_arrc[] = {INT_MAX, 3, 2, 1, 1};
+    using C                 = std::greater<long>;
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      std::flat_multiset m(std::begin(arr), std::end(arr), C());
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // const
+      std::flat_multiset m(std::begin(arrc), std::end(arrc), C());
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      std::flat_multiset m(std::sorted_equivalent, std::begin(sorted_arr), std::end(sorted_arr), C());
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // const
+      std::flat_multiset m(std::sorted_equivalent, std::begin(sorted_arrc), std::end(sorted_arrc), C());
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // flat_multiset iterator
+      std::flat_multiset<int> mo;
+      std::flat_multiset m(mo.begin(), mo.end(), C());
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+    }
+    {
+      // template<class InputIterator, class Compare = less<iter-value-type<InputIterator>>>
+      // flat_multiset(InputIterator, InputIterator, Compare = Compare())
+      //   -> flat_multiset<iter-value-type<InputIterator>, Compare>;
+      // flat_multiset const_iterator
+      std::flat_multiset<int> mo;
+      std::flat_multiset m(mo.cbegin(), mo.cend(), C());
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+    }
+  }
+  {
+    const int sorted_arr[] = {1, 1, 2, 3, INT_MAX};
+    {
+      // template<class Key, class Compare = less<Key>>
+      // flat_multiset(initializer_list<Key>, Compare = Compare())
+      //   -> flat_multiset<Key, Compare>;
+      std::flat_multiset m{1, 2, 1, INT_MAX, 3};
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class Key, class Compare = less<Key>>
+      // flat_multiset(sorted_equivalent_t, initializer_list<Key>, Compare = Compare())
+      //     -> flat_multiset<Key, Compare>;
+      std::flat_multiset m(std::sorted_equivalent, {1, 1, 2, 3, INT_MAX});
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // One element with brace was treated as initializer_list
+      std::flat_multiset s = {1};
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int>);
+      assert(s.size() == 1);
+    }
+    {
+      // Two elements with brace was treated as initializer_list
+      using M = std::flat_multiset<int>;
+      M m;
+      std::flat_multiset s{m, m}; // flat_multiset(initializer_list<M>)
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<M>);
+      assert(s.size() == 2);
+    }
+  }
+  {
+    const int sorted_arr[] = {INT_MAX, 3, 2, 1, 1};
+    using C                = std::greater<long>;
+    {
+      // template<class Key, class Compare = less<Key>>
+      // flat_multiset(initializer_list<Key>, Compare = Compare())
+      //   -> flat_multiset<Key, Compare>;
+      std::flat_multiset m({1, 2, 1, INT_MAX, 3}, C());
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+    {
+      // template<class Key, class Compare = less<Key>>
+      // flat_multiset(sorted_equivalent_t, initializer_list<Key>, Compare = Compare())
+      //     -> flat_multiset<Key, Compare>;
+      std::flat_multiset m(std::sorted_equivalent, {INT_MAX, 3, 2, 1, 1}, C());
+
+      ASSERT_SAME_TYPE(decltype(m), std::flat_multiset<int, C>);
+      assert(std::ranges::equal(m, sorted_arr));
+    }
+  }
+  {
+    std::list<int> r     = {1, 2, 1, INT_MAX, 3};
+    const int expected[] = {1, 1, 2, 3, INT_MAX};
+    {
+      // template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
+      //     class Allocator = allocator<ranges::range_value_t<R>>>
+      // flat_multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
+      // -> flat_multiset<ranges::range_value_t<R>, Compare,
+      //                 vector<ranges::range_value_t<R>,
+      //                        alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
+      std::flat_multiset s(std::from_range, r);
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>>);
+      assert(std::ranges::equal(s, expected));
+    }
+    {
+      // template<ranges::input_range R, class Allocator>
+      // flat_multiset(from_range_t, R&&, Allocator)
+      //   -> flat_multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>,
+      //                    vector<ranges::range_value_t<R>,
+      //                           alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
+      std::flat_multiset s(std::from_range, r, test_allocator<long>(0, 42));
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>, std::vector<int, test_allocator<int>>>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 42);
+    }
+  }
+
+  {
+    // with comparator
+    std::list<int> r     = {1, 2, 1, INT_MAX, 3};
+    const int expected[] = {INT_MAX, 3, 2, 1, 1};
+    {
+      // template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
+      //     class Allocator = allocator<ranges::range_value_t<R>>>
+      // flat_multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
+      // -> flat_multiset<ranges::range_value_t<R>, Compare,
+      //                 vector<ranges::range_value_t<R>,
+      //                        alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
+      std::flat_multiset s(std::from_range, r, std::greater<int>());
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>>);
+      assert(std::ranges::equal(s, expected));
+    }
+    {
+      // template<ranges::input_range R, class Allocator>
+      // flat_multiset(from_range_t, R&&, Allocator)
+      //   -> flat_multiset<ranges::range_value_t<R>, less<ranges::range_value_t<R>>,
+      //                    vector<ranges::range_value_t<R>,
+      //                           alloc-rebind<Allocator, ranges::range_value_t<R>>>>;
+      std::flat_multiset s(std::from_range, r, std::greater<int>(), test_allocator<long>(0, 42));
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>, std::vector<int, test_allocator<int>>>);
+      assert(std::ranges::equal(s, expected));
+      assert(std::move(s).extract().get_allocator().get_id() == 42);
+    }
+  }
+
+  AssociativeContainerDeductionGuidesSfinaeAway<std::flat_multiset, std::flat_multiset<int>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct_pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct_pmr.pass.cpp
new file mode 100644
index 0000000000000..367dc55e34410
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/deduct_pmr.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: availability-pmr-missing
+
+// <flat_set>
+
+#include <algorithm>
+#include <cassert>
+#include <climits>
+#include <deque>
+#include <initializer_list>
+#include <list>
+#include <flat_set>
+#include <functional>
+#include <memory_resource>
+#include <ranges>
+#include <type_traits>
+#include <utility>
+#include <vector>
+
+#include "test_allocator.h"
+
+using P  = std::pair<int, long>;
+using PC = std::pair<const int, long>;
+
+int main(int, char**) {
+  {
+    std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
+    std::deque<int, test_allocator<int>> sorted_ks({1, 1, 2, 3, INT_MAX}, test_allocator<int>(0, 42));
+    const int expected[] = {1, 1, 2, 3, INT_MAX};
+    {
+      // template<class KeyContainer, class Allocator>
+      // flat_multiset(KeyContainer, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type,
+      //                    less<typename KeyContainer::value_type>, KeyContainer>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::monotonic_buffer_resource mr2;
+      std::pmr::deque<int> pks(ks.begin(), ks.end(), &mr);
+      std::flat_multiset s(std::move(pks), &mr2);
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>, std::pmr::deque<int>>);
+      assert(std::ranges::equal(s, expected));
+      auto keys = std::move(s).extract();
+      assert(keys.get_allocator().resource() == &mr2);
+    }
+    {
+      // template<class KeyContainer, class Allocator>
+      // flat_multiset(sorted_equivalent_t, KeyContainer, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type,
+      //                    less<typename KeyContainer::value_type>, KeyContainer>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::monotonic_buffer_resource mr2;
+      std::pmr::deque<int> pks(sorted_ks.begin(), sorted_ks.end(), &mr);
+      std::flat_multiset s(std::sorted_equivalent, std::move(pks), &mr2);
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::less<int>, std::pmr::deque<int>>);
+      assert(std::ranges::equal(s, expected));
+      auto keys = std::move(s).extract();
+      assert(keys.get_allocator().resource() == &mr2);
+    }
+  }
+  {
+    std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
+    std::deque<int, test_allocator<int>> sorted_ks({INT_MAX, 3, 2, 1, 1}, test_allocator<int>(0, 42));
+    const int expected[] = {INT_MAX, 3, 2, 1, 1};
+    {
+      // template<class KeyContainer, class Compare, class Allocator>
+      // flat_multiset(KeyContainer, Compare, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::monotonic_buffer_resource mr2;
+      std::pmr::deque<int> pks(ks.begin(), ks.end(), &mr);
+      std::flat_multiset s(std::move(pks), std::greater<int>(), &mr2);
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>, std::pmr::deque<int>>);
+      assert(std::ranges::equal(s, expected));
+      auto keys = std::move(s).extract();
+      assert(keys.get_allocator().resource() == &mr2);
+    }
+    {
+      // template<class KeyContainer, class Compare, class Allocator>
+      // flat_multiset(sorted_equivalent_t, KeyContainer, Compare, Allocator)
+      //   -> flat_multiset<typename KeyContainer::value_type, Compare, KeyContainer>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::monotonic_buffer_resource mr2;
+      std::pmr::deque<int> pks(sorted_ks.begin(), sorted_ks.end(), &mr);
+      std::flat_multiset s(std::sorted_equivalent, std::move(pks), std::greater<int>(), &mr2);
+
+      ASSERT_SAME_TYPE(decltype(s), std::flat_multiset<int, std::greater<int>, std::pmr::deque<int>>);
+      assert(std::ranges::equal(s, expected));
+      auto keys = std::move(s).extract();
+      assert(keys.get_allocator().resource() == &mr2);
+    }
+  }
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp
new file mode 100644
index 0000000000000..16f90322cd31a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset();
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <type_traits>
+#include <vector>
+
+#include "min_allocator.h"
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "test_macros.h"
+
+struct DefaultCtableComp {
+  explicit DefaultCtableComp() { default_constructed_ = true; }
+  bool operator()(int, int) const { return false; }
+  bool default_constructed_ = false;
+};
+
+struct ThrowingCtorComp {
+  ThrowingCtorComp() noexcept(false) {}
+  bool operator()(const auto&, const auto&) const { return false; }
+};
+
+void test() {
+  {
+    std::flat_multiset<int> m;
+    assert(m.empty());
+  }
+  {
+    // explicit(false)
+    std::flat_multiset<int> m = {};
+    assert(m.empty());
+  }
+  {
+    std::flat_multiset<int, DefaultCtableComp, std::deque<int, min_allocator<int>>> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp().default_constructed_);
+  }
+  {
+    using A1 = explicit_allocator<int>;
+    {
+      std::flat_multiset<int, DefaultCtableComp, std::vector<int, A1>> m;
+      assert(m.empty());
+      assert(m.key_comp().default_constructed_);
+    }
+    {
+      A1 a1;
+      std::flat_multiset<int, DefaultCtableComp, std::vector<int, A1>> m(a1);
+      assert(m.empty());
+      assert(m.key_comp().default_constructed_);
+    }
+  }
+#if defined(_LIBCPP_VERSION)
+  {
+    using C = std::flat_multiset<MoveOnly>;
+    static_assert(std::is_nothrow_default_constructible_v<C>);
+    C c;
+  }
+  {
+    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;
+    static_assert(std::is_nothrow_default_constructible_v<C>);
+    C c;
+  }
+#endif // _LIBCPP_VERSION
+  {
+    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;
+    static_assert(!std::is_nothrow_default_constructible_v<C>);
+    C c;
+  }
+  {
+    using C = std::flat_multiset<MoveOnly, ThrowingCtorComp>;
+    static_assert(!std::is_nothrow_default_constructible_v<C>);
+    C c;
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000000000..f852f2f85572c
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// ~flat_multiset();
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "test_macros.h"
+#include "MoveOnly.h"
+#include "test_allocator.h"
+
+struct ThrowingDtorComp {
+  bool operator()(const auto&, const auto&) const;
+  ~ThrowingDtorComp() noexcept(false) {}
+};
+
+void test() {
+  {
+    using C = std::flat_multiset<MoveOnly, MoveOnly>;
+    static_assert(std::is_nothrow_destructible_v<C>);
+    C c;
+  }
+  {
+    using V = std::vector<MoveOnly, test_allocator<MoveOnly>>;
+    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, V>;
+    static_assert(std::is_nothrow_destructible_v<C>);
+    C c;
+  }
+  {
+    using V = std::deque<MoveOnly, other_allocator<MoveOnly>>;
+    using C = std::flat_multiset<MoveOnly, std::greater<MoveOnly>, V>;
+    static_assert(std::is_nothrow_destructible_v<C>);
+    C c;
+  }
+#if defined(_LIBCPP_VERSION)
+  {
+    using C = std::flat_multiset<MoveOnly, ThrowingDtorComp>;
+    static_assert(!std::is_nothrow_destructible_v<C>);
+    C c;
+  }
+#endif // _LIBCPP_VERSION
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000000000..10638d75bbd14
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/initializer_list.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+// template<class Alloc>
+//    flat_multiset(initializer_list<value_type> il, const Alloc& a);
+// template<class Alloc>
+//    flat_multiset(initializer_list<value_type> il, const key_compare& comp, const Alloc& a);
+
+#include <algorithm>
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <type_traits>
+#include <vector>
+#include <ranges>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+
+#include "../../../test_compare.h"
+
+struct DefaultCtableComp {
+  explicit DefaultCtableComp() { default_constructed_ = true; }
+  bool operator()(int, int) const { return false; }
+  bool default_constructed_ = false;
+};
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    using IL = std::initializer_list<int>;
+    static_assert(std::is_constructible_v<M1, IL, const A1&>);
+    static_assert(std::is_constructible_v<M2, IL, const A2&>);
+    static_assert(!std::is_constructible_v<M1, IL, const A2&>);
+    static_assert(!std::is_constructible_v<M2, IL, const A1&>);
+
+    static_assert(std::is_constructible_v<M1, IL, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, IL, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, IL, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, IL, const C&, const A1&>);
+  }
+
+  {
+    // initializer_list<value_type> needs to match exactly
+    using M = std::flat_multiset<int>;
+    using C = typename M::key_compare;
+    static_assert(std::is_constructible_v<M, std::initializer_list<int>>);
+    static_assert(std::is_constructible_v<M, std::initializer_list<int>, C>);
+    static_assert(std::is_constructible_v<M, std::initializer_list<int>, C, std::allocator<int>>);
+    static_assert(std::is_constructible_v<M, std::initializer_list<int>, std::allocator<int>>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
+    static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
+  }
+
+  int expected[] = {1, 2, 2, 3, 3, 5};
+  {
+    // flat_multiset(initializer_list<value_type>);
+    using M                       = std::flat_multiset<int>;
+    std::initializer_list<int> il = {5, 2, 2, 3, 1, 3};
+    M m(il);
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    // flat_multiset(initializer_list<value_type>);
+    // explicit(false)
+    using M = std::flat_multiset<int>;
+    M m     = {5, 2, 2, 3, 1, 3};
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    // flat_multiset(initializer_list<value_type>);
+    using M = std::flat_multiset<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+    M m     = {5, 2, 2, 3, 1, 3};
+    assert(std::ranges::equal(m, expected | std::views::reverse));
+  }
+  {
+    using A = explicit_allocator<int>;
+    {
+      // flat_multiset(initializer_list<value_type>);
+      // 
diff erent comparator
+      using M = std::flat_multiset<int, DefaultCtableComp, std::vector<int, A>>;
+      M m     = {1, 2, 3};
+      assert(m.size() == 3);
+      LIBCPP_ASSERT(*m.begin() == 1);
+      assert(m.key_comp().default_constructed_);
+    }
+    {
+      // flat_multiset(initializer_list<value_type>, const Allocator&);
+      using M = std::flat_multiset<int, std::greater<int>, std::deque<int, A>>;
+      A a;
+      M m({5, 2, 2, 3, 1, 3}, a);
+      assert(std::ranges::equal(m, expected | std::views::reverse));
+    }
+  }
+  {
+    // flat_multiset(initializer_list<value_type>, const key_compare&);
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C>;
+    auto m  = M({5, 2, 2, 3, 1, 3}, C(10));
+    assert(std::ranges::equal(m, expected));
+    assert(m.key_comp() == C(10));
+
+    // explicit(false)
+    M m2 = {{5, 2, 2, 1, 3, 3}, C(10)};
+    assert(m2 == m);
+    assert(m2.key_comp() == C(10));
+  }
+  {
+    // flat_multiset(initializer_list<value_type>, const key_compare&);
+    // Sorting uses the comparator that was passed in
+    using M = std::flat_multiset<int, std::function<bool(int, int)>, std::deque<int, min_allocator<int>>>;
+    auto m  = M({5, 2, 2, 1, 3, 3}, std::greater<int>());
+    assert(std::ranges::equal(m, expected | std::views::reverse));
+    assert(m.key_comp()(2, 1) == true);
+  }
+  {
+    // flat_multiset(initializer_list<value_type> il, const key_compare& comp, const Alloc& a);
+    using A = explicit_allocator<int>;
+    using M = std::flat_multiset<int, std::greater<int>, std::deque<int, A>>;
+    A a;
+    M m({5, 2, 2, 3, 1, 3}, {}, a);
+    assert(std::ranges::equal(m, expected | std::views::reverse));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000000000..da9aef3dc36cd
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/iter_iter.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template <class InputIterator>
+//   flat_multiset(InputIterator first, InputIterator last, const key_compare& comp = key_compare());
+// template<class InputIterator, class Allocator>
+//   flat_multiset(InputIterator first, InputIterator last, const Allocator& a);
+// template<class InputIterator, class Allocator>
+//   flat_multiset(InputIterator first, InputIterator last, const key_compare& comp, const Allocator& a);
+
+#include <algorithm>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <ranges>
+#include <vector>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C     = test_less<int>;
+    using A1    = test_allocator<int>;
+    using A2    = other_allocator<int>;
+    using V1    = std::vector<int, A1>;
+    using V2    = std::vector<int, A2>;
+    using M1    = std::flat_multiset<int, C, V1>;
+    using M2    = std::flat_multiset<int, C, V2>;
+    using Iter1 = typename M1::iterator;
+    using Iter2 = typename M2::iterator;
+    static_assert(std::is_constructible_v<M1, Iter1, Iter1, const A1&>);
+    static_assert(std::is_constructible_v<M2, Iter2, Iter2, const A2&>);
+    static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const A2&>);
+    static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const A1&>);
+
+    static_assert(std::is_constructible_v<M1, Iter1, Iter1, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, Iter2, Iter2, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const C&, const A1&>);
+  }
+
+  int ar[]       = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+  int expected[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
+  {
+    // flat_multiset(InputIterator , InputIterator)
+    // cpp17_input_iterator
+    using M = std::flat_multiset<int>;
+    auto m  = M(cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 9));
+    assert(std::ranges::equal(m, expected));
+
+    // explicit(false)
+    M m2 = {cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 9)};
+    assert(m2 == m);
+  }
+  {
+    // flat_multiset(InputIterator , InputIterator)
+    // greater
+    using M = std::flat_multiset<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+    auto m  = M(cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 9));
+    assert(std::ranges::equal(m, expected | std::views::reverse));
+  }
+  {
+    // flat_multiset(InputIterator , InputIterator)
+    // Test when the operands are of array type (also contiguous iterator type)
+    using M = std::flat_multiset<int, std::greater<int>, std::vector<int, min_allocator<int>>>;
+    auto m  = M(ar, ar);
+    assert(m.empty());
+  }
+  {
+    // flat_multiset(InputIterator , InputIterator, const key_compare&)
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::vector<int>>;
+    auto m  = M(ar, ar + 9, C(3));
+    assert(std::ranges::equal(m, expected));
+    assert(m.key_comp() == C(3));
+
+    // explicit(false)
+    M m2 = {ar, ar + 9, C(3)};
+    assert(m2 == m);
+    assert(m2.key_comp() == C(3));
+  }
+  {
+    // flat_multiset(InputIterator , InputIterator, const Allocator&)
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, std::less<int>, std::vector<int, A1>>;
+    auto m   = M(ar, ar + 9, A1(5));
+    assert(std::ranges::equal(m, expected));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(InputIterator , InputIterator, const Allocator&)
+    // explicit(false)
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, std::less<int>, std::vector<int, A1>>;
+    M m      = {ar, ar + 9, A1(5)}; // implicit ctor
+    assert(std::ranges::equal(m, expected));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(InputIterator , InputIterator, const key_compare&, const Allocator&)
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, C, std::vector<int, A1>>;
+    auto m   = M(ar, ar + 9, C(3), A1(5));
+    assert(std::ranges::equal(m, expected));
+    assert(m.key_comp() == C(3));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(InputIterator , InputIterator, const key_compare&, const Allocator&)
+    // explicit(false)
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, std::less<int>, std::deque<int, A1>>;
+    M m      = {ar, ar + 9, {}, A1(5)}; // implicit ctor
+    assert(std::ranges::equal(m, expected));
+    LIBCPP_ASSERT(std::ranges::equal(m, expected));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
new file mode 100644
index 0000000000000..825ad75cc8f4c
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
@@ -0,0 +1,188 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset(flat_multiset&&);
+
+#include <algorithm>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+#include <vector>
+
+#include "../helpers.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+void test() {
+  {
+    using C = test_less<int>;
+    using A = test_allocator<int>;
+    using M = std::flat_multiset<int, C, std::deque<int, A>>;
+    M mo    = M({1, 2, 1, 3}, C(5), A(7));
+    M m     = std::move(mo);
+    assert((m == M{1, 1, 2, 3}));
+    assert(m.key_comp() == C(5));
+    assert(std::move(m).extract().get_allocator() == A(7));
+
+    assert(mo.empty());
+    assert(mo.key_comp() == C(5));
+    assert(std::move(mo).extract().get_allocator().get_id() == test_alloc_base::moved_value);
+  }
+  {
+    using C = test_less<int>;
+    using A = min_allocator<int>;
+    using M = std::flat_multiset<int, C, std::vector<int, A>>;
+    M mo    = M({1, 2, 1, 3}, C(5), A());
+    M m     = std::move(mo);
+    assert((m == M{1, 1, 2, 3}));
+    assert(m.key_comp() == C(5));
+    assert(std::move(m).extract().get_allocator() == A());
+
+    assert(mo.empty());
+    assert(mo.key_comp() == C(5));
+    assert(std::move(mo).extract().get_allocator() == A());
+  }
+  {
+    // A moved-from flat_multiset maintains its class invariant in the presence of moved-from comparators.
+    using M = std::flat_multiset<int, std::function<bool(int, int)>>;
+    M mo    = M({1, 2, 1, 3}, std::less<int>());
+    M m     = std::move(mo);
+    assert(m.size() == 4);
+    assert(std::is_sorted(m.begin(), m.end(), m.value_comp()));
+    assert(m.key_comp()(1, 2) == true);
+
+    assert(std::is_sorted(mo.begin(), mo.end(), mo.value_comp()));
+    LIBCPP_ASSERT(m.key_comp()(1, 2) == true);
+    LIBCPP_ASSERT(mo.empty());
+    mo.insert({1, 1, 2, 3}); // insert has no preconditions
+    assert(m == mo);
+  }
+  {
+    // moved-from object maintains invariant if the underlying container does not clear after move
+    using M = std::flat_multiset<int, std::less<>, CopyOnlyVector<int>>;
+    M m1    = M({1, 2, 1, 3});
+    M m2    = std::move(m1);
+    assert(m2.size() == 4);
+    check_invariant(m1);
+    LIBCPP_ASSERT(m1.empty());
+    LIBCPP_ASSERT(m1.size() == 0);
+  }
+}
+
+template <class T>
+struct ThrowingMoveAllocator {
+  using value_type                                    = T;
+  explicit ThrowingMoveAllocator()                    = default;
+  ThrowingMoveAllocator(const ThrowingMoveAllocator&) = default;
+  ThrowingMoveAllocator(ThrowingMoveAllocator&&) noexcept(false) {}
+  T* allocate(std::ptr
diff _t n) { return std::allocator<T>().allocate(n); }
+  void deallocate(T* p, std::ptr
diff _t n) { return std::allocator<T>().deallocate(p, n); }
+  friend bool operator==(ThrowingMoveAllocator, ThrowingMoveAllocator) = default;
+};
+
+struct ThrowingMoveComp {
+  ThrowingMoveComp() = default;
+  ThrowingMoveComp(const ThrowingMoveComp&) noexcept(true) {}
+  ThrowingMoveComp(ThrowingMoveComp&&) noexcept(false) {}
+  bool operator()(const auto&, const auto&) const { return false; }
+};
+
+struct MoveSensitiveComp {
+  MoveSensitiveComp() noexcept(false)                  = default;
+  MoveSensitiveComp(const MoveSensitiveComp&) noexcept = default;
+  MoveSensitiveComp(MoveSensitiveComp&& rhs) { rhs.is_moved_from_ = true; }
+  MoveSensitiveComp& operator=(const MoveSensitiveComp&) noexcept(false) = default;
+  MoveSensitiveComp& operator=(MoveSensitiveComp&& rhs) {
+    rhs.is_moved_from_ = true;
+    return *this;
+  }
+  bool operator()(const auto&, const auto&) const { return false; }
+  bool is_moved_from_ = false;
+};
+
+void test_move_noexcept() {
+  {
+    using C = std::flat_multiset<int>;
+    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
+    C c;
+    C d = std::move(c);
+  }
+  {
+    using C = std::flat_multiset<int, std::less<int>, std::deque<int, test_allocator<int>>>;
+    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
+    C c;
+    C d = std::move(c);
+  }
+#if _LIBCPP_VERSION
+  {
+    // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
+    using C = std::flat_multiset<int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>>;
+    static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
+    static_assert(!std::is_nothrow_move_constructible_v<C>);
+    C c;
+    C d = std::move(c);
+  }
+#endif // _LIBCPP_VERSION
+  {
+    // Comparator fails to be nothrow-move-constructible
+    using C = std::flat_multiset<int, ThrowingMoveComp>;
+    static_assert(!std::is_nothrow_move_constructible_v<C>);
+    C c;
+    C d = std::move(c);
+  }
+}
+
+#if !defined(TEST_HAS_NO_EXCEPTIONS)
+static int countdown = 0;
+
+struct EvilContainer : std::vector<int> {
+  EvilContainer() = default;
+  EvilContainer(EvilContainer&& rhs) {
+    // Throw on move-construction.
+    if (--countdown == 0) {
+      rhs.insert(rhs.end(), 0);
+      rhs.insert(rhs.end(), 0);
+      throw 42;
+    }
+  }
+};
+
+void test_move_exception() {
+  {
+    using M   = std::flat_multiset<int, std::less<int>, EvilContainer>;
+    M mo      = {1, 2, 3};
+    countdown = 1;
+    try {
+      M m = std::move(mo);
+      assert(false); // not reached
+    } catch (int x) {
+      assert(x == 42);
+    }
+    // The source flat_multiset maintains its class invariant.
+    check_invariant(mo);
+    LIBCPP_ASSERT(mo.empty());
+  }
+}
+#endif // !defined(TEST_HAS_NO_EXCEPTIONS)
+
+int main(int, char**) {
+  test();
+  test_move_noexcept();
+#if !defined(TEST_HAS_NO_EXCEPTIONS)
+  test_move_exception();
+#endif // !defined(TEST_HAS_NO_EXCEPTIONS)
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000000000..ee8258e5ac846
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset(flat_multiset&&, const allocator_type&);
+
+#include <algorithm>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <ranges>
+#include <vector>
+
+#include "../helpers.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    static_assert(std::is_constructible_v<M1, M1&&, const A1&>);
+    static_assert(std::is_constructible_v<M2, M2&&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, M1&&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, M2&&, const A1&>);
+  }
+  {
+    int expected[] = {1, 1, 2, 2, 3};
+    using C        = test_less<int>;
+    using A        = test_allocator<int>;
+    using M        = std::flat_multiset<int, C, std::deque<int, A>>;
+    auto mo        = M(expected, expected + 5, C(5), A(7));
+    auto m         = M(std::move(mo), A(3));
+
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 5);
+    auto keys = std::move(m).extract();
+    assert(keys.get_allocator() == A(3));
+    assert(std::ranges::equal(keys, expected));
+
+    // The original flat_multiset is moved-from.
+    assert(std::is_sorted(mo.begin(), mo.end(), mo.value_comp()));
+    assert(mo.empty());
+    assert(mo.key_comp() == C(5));
+    assert(std::move(mo).extract().get_allocator() == A(7));
+  }
+  {
+    // moved-from object maintains invariant if one of underlying container does not clear after move
+    using M = std::flat_multiset<int, std::less<>, CopyOnlyVector<int>>;
+    M m1    = M({1, 2, 2, 1, 3});
+    M m2(std::move(m1), std::allocator<int>{});
+    assert(m2.size() == 5);
+    assert(std::ranges::is_sorted(m1));
+    LIBCPP_ASSERT(m1.empty());
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_assign.pass.cpp
new file mode 100644
index 0000000000000..96e046e38668f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_assign.pass.cpp
@@ -0,0 +1,239 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset& operator=(flat_multiset&&);
+
+#include <algorithm>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "test_macros.h"
+#include "MoveOnly.h"
+#include "../helpers.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+struct MoveNegates {
+  int value_    = 0;
+  MoveNegates() = default;
+  MoveNegates(int v) : value_(v) {}
+  MoveNegates(MoveNegates&& rhs) : value_(rhs.value_) { rhs.value_ = -rhs.value_; }
+  MoveNegates& operator=(MoveNegates&& rhs) {
+    value_     = rhs.value_;
+    rhs.value_ = -rhs.value_;
+    return *this;
+  }
+  ~MoveNegates()                             = default;
+  auto operator<=>(const MoveNegates&) const = default;
+};
+
+struct MoveClears {
+  int value_   = 0;
+  MoveClears() = default;
+  MoveClears(int v) : value_(v) {}
+  MoveClears(MoveClears&& rhs) : value_(rhs.value_) { rhs.value_ = 0; }
+  MoveClears& operator=(MoveClears&& rhs) {
+    value_     = rhs.value_;
+    rhs.value_ = 0;
+    return *this;
+  }
+  ~MoveClears()                             = default;
+  auto operator<=>(const MoveClears&) const = default;
+};
+
+#if !defined(TEST_HAS_NO_EXCEPTIONS)
+struct MoveAssignThrows : std::vector<int> {
+  using std::vector<int>::vector;
+  MoveAssignThrows& operator=(MoveAssignThrows&& other) {
+    push_back(0);
+    push_back(0);
+    other.push_back(0);
+    other.push_back(0);
+    throw 42;
+  }
+};
+#endif // TEST_HAS_NO_EXCEPTIONS
+
+void test_move_assign_clears() {
+  // Preserves the class invariant for the moved-from flat_multiset.
+  {
+    const int expected[] = {1, 1, 2, 3, 4, 5, 6, 7, 8};
+    using M              = std::flat_multiset<MoveNegates, std::less<MoveNegates>>;
+    M m                  = M(expected, expected + 9);
+    M m2                 = M(expected, expected + 4);
+
+    m2 = std::move(m);
+
+    assert(std::equal(m2.begin(), m2.end(), expected, expected + 9));
+    LIBCPP_ASSERT(m.empty());
+    check_invariant(m);
+    m.insert(1);
+    m.insert(2);
+    assert(m.contains(1));
+    assert(m.find(2) != m.end());
+  }
+  {
+    const int expected[] = {1, 1, 2, 3, 4, 5, 6, 7, 8};
+    using M              = std::flat_multiset<MoveClears, std::less<MoveClears>>;
+    M m                  = M(expected, expected + 9);
+    M m2                 = M(expected, expected + 4);
+
+    m2 = std::move(m);
+
+    assert(std::equal(m2.begin(), m2.end(), expected, expected + 9));
+    LIBCPP_ASSERT(m.empty());
+    check_invariant(m);
+    m.insert(1);
+    m.insert(2);
+    assert(m.contains(1));
+    assert(m.find(2) != m.end());
+  }
+  {
+    // moved-from object maintains invariant if the underlying container does not clear after move
+    using M = std::flat_multiset<int, std::less<>, CopyOnlyVector<int>>;
+    M m1    = M({1, 1, 2, 3});
+    M m2    = M({1, 2});
+    m2      = std::move(m1);
+    assert(m2.size() == 4);
+    check_invariant(m1);
+    LIBCPP_ASSERT(m1.empty());
+  }
+#if !defined(TEST_HAS_NO_EXCEPTIONS)
+  {
+    using M = std::flat_multiset<int, std::less<>, MoveAssignThrows>;
+    M m1    = {1, 1, 2, 3};
+    M m2    = {1, 1, 2};
+    try {
+      m2 = std::move(m1);
+      assert(false);
+    } catch (int e) {
+      assert(e == 42);
+    }
+    check_invariant(m1);
+    check_invariant(m2);
+    LIBCPP_ASSERT(m1.empty());
+    LIBCPP_ASSERT(m2.empty());
+  }
+#endif // TEST_HAS_NO_EXCEPTIONS
+}
+
+struct MoveSensitiveComp {
+  MoveSensitiveComp() noexcept(false)                         = default;
+  MoveSensitiveComp(const MoveSensitiveComp&) noexcept(false) = default;
+  MoveSensitiveComp(MoveSensitiveComp&& rhs) { rhs.is_moved_from_ = true; }
+  MoveSensitiveComp& operator=(const MoveSensitiveComp&) noexcept = default;
+  MoveSensitiveComp& operator=(MoveSensitiveComp&& rhs) {
+    rhs.is_moved_from_ = true;
+    return *this;
+  }
+  bool operator()(const auto&, const auto&) const { return false; }
+  bool is_moved_from_ = false;
+};
+
+struct MoveThrowsComp {
+  MoveThrowsComp(MoveThrowsComp&&) noexcept(false);
+  MoveThrowsComp(const MoveThrowsComp&) noexcept(true);
+  MoveThrowsComp& operator=(MoveThrowsComp&&) noexcept(false);
+  MoveThrowsComp& operator=(const MoveThrowsComp&) noexcept(true);
+  bool operator()(const auto&, const auto&) const;
+};
+
+void test_move_assign_no_except() {
+  // This tests a conforming extension
+
+  {
+    using C = std::flat_multiset<int, int>;
+    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
+  }
+  {
+    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;
+    static_assert(!std::is_nothrow_move_assignable_v<C>);
+  }
+  {
+    using C = std::flat_multiset<int, std::less<int>, std::vector<int, test_allocator<int>>>;
+    static_assert(!std::is_nothrow_move_assignable_v<C>);
+  }
+  {
+    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;
+    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
+  }
+  {
+    using C = std::flat_multiset<int, std::less<int>, std::vector<int, other_allocator<int>>>;
+    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
+  }
+  {
+    // Test with a comparator that throws on move-assignment.
+    using C = std::flat_multiset<int, MoveThrowsComp>;
+    LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v<C>);
+  }
+  {
+    // Test with a container that throws on move-assignment.
+    using C = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+    static_assert(!std::is_nothrow_move_assignable_v<C>);
+  }
+}
+
+void test() {
+  {
+    using C                           = test_less<int>;
+    using A1                          = test_allocator<int>;
+    using M                           = std::flat_multiset<int, C, std::vector<int, A1>>;
+    M mo                              = M({1, 1, 2, 3}, C(5), A1(7));
+    M m                               = M({}, C(3), A1(7));
+    std::same_as<M&> decltype(auto) r = m = std::move(mo);
+    assert(&r == &m);
+    assert((m == M{1, 1, 2, 3}));
+    assert(m.key_comp() == C(5));
+    auto ks = std::move(m).extract();
+    assert(ks.get_allocator() == A1(7));
+    assert(mo.empty());
+  }
+  {
+    using C                           = test_less<int>;
+    using A1                          = other_allocator<int>;
+    using M                           = std::flat_multiset<int, C, std::deque<int, A1>>;
+    M mo                              = M({4, 4, 5}, C(5), A1(7));
+    M m                               = M({1, 1, 2, 3, 4}, C(3), A1(7));
+    std::same_as<M&> decltype(auto) r = m = std::move(mo);
+    assert(&r == &m);
+    assert((m == M{4, 4, 5}));
+    assert(m.key_comp() == C(5));
+    auto ks = std::move(m).extract();
+    assert(ks.get_allocator() == A1(7));
+    assert(mo.empty());
+  }
+  {
+    using A                           = min_allocator<int>;
+    using M                           = std::flat_multiset<int, std::greater<int>, std::vector<int, A>>;
+    M mo                              = M({5, 3, 4, 3}, A());
+    M m                               = M({4, 1, 3, 2, 1}, A());
+    std::same_as<M&> decltype(auto) r = m = std::move(mo);
+    assert(&r == &m);
+    assert((m == M{5, 4, 3, 3}));
+    auto ks = std::move(m).extract();
+    assert(ks.get_allocator() == A());
+    assert(mo.empty());
+  }
+}
+
+int main(int, char**) {
+  test();
+  test_move_assign_clears();
+  test_move_assign_no_except();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/pmr.pass.cpp
new file mode 100644
index 0000000000000..381aafb00d4fa
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/pmr.pass.cpp
@@ -0,0 +1,326 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: availability-pmr-missing
+
+// <flat_set>
+
+// Test various constructors with pmr
+
+#include <algorithm>
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <memory_resource>
+#include <ranges>
+#include <vector>
+#include <string>
+
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "../helpers.h"
+#include "../../../test_compare.h"
+
+void test() {
+  {
+    // flat_multiset(const Allocator& a);
+    using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::polymorphic_allocator<int> pa = &mr;
+    auto m1                                 = M(pa);
+    assert(m1.empty());
+    assert(std::move(m1).extract().get_allocator() == pa);
+    auto m2 = M(&mr);
+    assert(m2.empty());
+    assert(std::move(m2).extract().get_allocator() == pa);
+  }
+  {
+    // flat_multiset(const key_compare& comp, const Alloc& a);
+    using M = std::flat_multiset<int, std::function<bool(int, int)>, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    vm.emplace_back(std::greater<int>());
+    assert(vm[0] == M{});
+    assert(vm[0].key_comp()(2, 1) == true);
+    assert(vm[0].value_comp()(2, 1) == true);
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    // flat_multiset(const container_type& key_cont, const Allocator& a);
+    using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    std::pmr::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+    assert(ks.get_allocator().resource() != &mr);
+    vm.emplace_back(ks);
+    assert(ks.size() == 9); // ks' value is unchanged, since it was an lvalue above
+    assert((vm[0] == M{1, 1, 1, 2, 2, 2, 3, 3, 3}));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    // flat_multiset(const flat_multiset&, const allocator_type&);
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr1;
+    std::pmr::monotonic_buffer_resource mr2;
+    M mo = M({1, 2, 3}, C(5), &mr1);
+    M m  = {mo, &mr2}; // also test the implicitness of this constructor
+
+    assert(m.key_comp() == C(5));
+    auto keys = std::move(m).extract();
+    assert((keys == std::pmr::vector<int>{1, 2, 3}));
+    assert(keys.get_allocator().resource() == &mr2);
+
+    // mo is unchanged
+    assert(mo.key_comp() == C(5));
+    auto keys2 = std::move(mo).extract();
+    assert((keys2 == std::pmr::vector<int>{1, 2, 3}));
+    assert(keys2.get_allocator().resource() == &mr1);
+  }
+  {
+    // flat_multiset(const flat_multiset&, const allocator_type&);
+    using M = std::flat_multiset<int, std::less<>, std::pmr::vector<int>>;
+    std::pmr::vector<M> vs;
+    M m = {1, 2, 3};
+    vs.push_back(m);
+    assert(vs[0] == m);
+  }
+  {
+    // flat_multiset& operator=(const flat_multiset& m);
+    // pmr allocator is not propagated
+    using M = std::flat_multiset<int, std::less<>, std::pmr::deque<int>>;
+    std::pmr::monotonic_buffer_resource mr1;
+    std::pmr::monotonic_buffer_resource mr2;
+    M mo = M({1, 2, 3}, &mr1);
+    M m  = M({4, 5}, &mr2);
+    m    = mo;
+    assert((m == M{1, 2, 3}));
+    assert(std::move(m).extract().get_allocator().resource() == &mr2);
+
+    // mo is unchanged
+    assert((mo == M{1, 2, 3}));
+    assert(std::move(mo).extract().get_allocator().resource() == &mr1);
+  }
+  {
+    // flat_multiset(const flat_multiset& m);
+    using C = test_less<int>;
+    std::pmr::monotonic_buffer_resource mr;
+    using M = std::flat_multiset<int, C, std::pmr::vector<int>>;
+    auto mo = M({1, 2, 3}, C(5), &mr);
+    auto m  = mo;
+
+    assert(m.key_comp() == C(5));
+    assert((m == M{1, 2, 3}));
+    auto ks = std::move(m).extract();
+    assert(ks.get_allocator().resource() == std::pmr::get_default_resource());
+
+    // mo is unchanged
+    assert(mo.key_comp() == C(5));
+    assert((mo == M{1, 2, 3}));
+    auto kso = std::move(mo).extract();
+    assert(kso.get_allocator().resource() == &mr);
+  }
+  {
+    //  flat_multiset(initializer_list<value_type> il, const Alloc& a);
+    using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    std::initializer_list<M::value_type> il = {3, 1, 4, 1, 5};
+    vm.emplace_back(il);
+    assert((vm[0] == M{1, 1, 3, 4, 5}));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    //  flat_multiset(initializer_list<value_type> il, const key_compare& comp, const Alloc& a);
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::pmr::deque<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    std::initializer_list<M::value_type> il = {3, 1, 4, 1, 5};
+    vm.emplace_back(il, C(5));
+    assert((vm[0] == M{1, 1, 3, 4, 5}));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+    assert(vm[0].key_comp() == C(5));
+  }
+  {
+    // flat_multiset(InputIterator first, InputIterator last, const Allocator& a);
+    int ar[]       = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+    int expected[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
+    {
+      //  cpp17 iterator
+      using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::vector<M> vm(&mr);
+      vm.emplace_back(cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 9));
+      assert(std::ranges::equal(vm[0], expected));
+      assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+    }
+    {
+      using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::vector<M> vm(&mr);
+      vm.emplace_back(ar, ar);
+      assert(vm[0].empty());
+      assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+    }
+  }
+  {
+    // flat_multiset(flat_multiset&&, const allocator_type&);
+    int expected[] = {1, 1, 2, 3};
+    using C        = test_less<int>;
+    using M        = std::flat_multiset<int, C, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr1;
+    std::pmr::monotonic_buffer_resource mr2;
+    M mo = M({1, 3, 1, 2}, C(5), &mr1);
+    M m  = {std::move(mo), &mr2}; // also test the implicitness of this constructor
+
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 4);
+    assert(std::ranges::equal(m, expected));
+    assert(std::move(m).extract().get_allocator().resource() == &mr2);
+
+    // The original flat_multiset is moved-from.
+    assert(std::is_sorted(mo.begin(), mo.end(), mo.value_comp()));
+    assert(mo.key_comp() == C(5));
+    assert(std::move(mo).extract().get_allocator().resource() == &mr1);
+  }
+  {
+    // flat_multiset(flat_multiset&&, const allocator_type&);
+    using M = std::flat_multiset<int, std::less<>, std::pmr::deque<int>>;
+    std::pmr::vector<M> vs;
+    M m = {1, 3, 1, 2};
+    vs.push_back(std::move(m));
+    assert((std::move(vs[0]).extract() == std::pmr::deque<int>{1, 1, 2, 3}));
+  }
+  {
+    // flat_multiset& operator=(flat_multiset&&);
+    using M = std::flat_multiset<std::pmr::string, std::less<>, std::pmr::vector<std::pmr::string>>;
+    std::pmr::monotonic_buffer_resource mr1;
+    std::pmr::monotonic_buffer_resource mr2;
+    M mo =
+        M({"short", "very long string that definitely won't fit in the SSO buffer and therefore becomes empty on move"},
+          &mr1);
+    M m = M({"don't care"}, &mr2);
+    m   = std::move(mo);
+    assert(m.size() == 2);
+    check_invariant(m);
+    assert(m.begin()->get_allocator().resource() == &mr2);
+
+    check_invariant(mo);
+    mo.insert("foo");
+    assert(mo.begin()->get_allocator().resource() == &mr1);
+  }
+  {
+    //  flat_multiset(from_range_t, R&&, const Alloc&);
+    int ar[]       = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+    int expected[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
+    {
+      // input_range
+      using M    = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+      using Iter = cpp20_input_iterator<const int*>;
+      using Sent = sentinel_wrapper<Iter>;
+      using R    = std::ranges::subrange<Iter, Sent>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::vector<M> vm(&mr);
+      vm.emplace_back(std::from_range, R(Iter(ar), Sent(Iter(ar + 9))));
+      assert(std::ranges::equal(vm[0], expected));
+      assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+    }
+    {
+      using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+      using R = std::ranges::subrange<const int*>;
+      std::pmr::monotonic_buffer_resource mr;
+      std::pmr::vector<M> vm(&mr);
+      vm.emplace_back(std::from_range, R(ar, ar));
+      assert(vm[0].empty());
+      assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+    }
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, const container_type& key_cont, const Alloc& a);
+    using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    std::pmr::vector<int> ks = {1, 1, 2, 4, 10};
+    vm.emplace_back(std::sorted_equivalent, ks);
+    assert(!ks.empty()); // it was an lvalue above
+    assert((vm[0] == M{1, 1, 2, 4, 10}));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, const container_type& key_cont,const Alloc& a);
+    using M = std::flat_multiset<int, std::less<int>, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    std::pmr::vector<int> ks({1, 1, 2, 4, 10}, &mr);
+    vm.emplace_back(std::sorted_equivalent, ks);
+    assert((vm[0] == M{1, 1, 2, 4, 10}));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type> il, const Alloc& a);
+    // cpp_17
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    int ar[] = {1, 1, 2, 4, 5};
+    vm.emplace_back(
+        std::sorted_equivalent, cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 5), C(3));
+    assert((vm[0] == M{1, 1, 2, 4, 5}));
+    assert(vm[0].key_comp() == C(3));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type> il, const Alloc& a);
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    int ar[1] = {42};
+    vm.emplace_back(std::sorted_equivalent, ar, ar, C(4));
+    assert(vm[0] == M{});
+    assert(vm[0].key_comp() == C(4));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    // flat_multiset(InputIterator first, InputIterator last, const Alloc& a);
+    // cpp_17
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    int ar[] = {1, 1, 2, 4, 5};
+    vm.emplace_back(
+        std::sorted_equivalent, cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 5), C(3));
+    assert((vm[0] == M{1, 1, 2, 4, 5}));
+    assert(vm[0].key_comp() == C(3));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+  {
+    // flat_multiset(InputIterator first, InputIterator last, const Alloc& a);
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::pmr::vector<int>>;
+    std::pmr::monotonic_buffer_resource mr;
+    std::pmr::vector<M> vm(&mr);
+    int ar[1] = {42};
+    vm.emplace_back(std::sorted_equivalent, ar, ar, C(4));
+    assert(vm[0] == M{});
+    assert(vm[0].key_comp() == C(4));
+    assert(std::move(vm[0]).extract().get_allocator().resource() == &mr);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/range.pass.cpp
new file mode 100644
index 0000000000000..76485b47ec5ea
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/range.pass.cpp
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<container-compatible-range<value_type> R>
+//     flat_multiset(from_range_t, R&&)
+// template<container-compatible-range<value_type> R>
+//     flat_multiset(from_range_t, R&&, const key_compare&)
+// template<container-compatible-range<value_type> R, class Alloc>
+//      flat_multiset(from_range_t, R&&, const Alloc&);
+// template<container-compatible-range<value_type> R, class Alloc>
+//      flat_multiset(from_range_t, R&&, const key_compare&, const Alloc&);
+
+#include <algorithm>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <vector>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+
+// test constraint container-compatible-range
+
+template <class V>
+using RangeOf = std::ranges::subrange<V*>;
+using Set     = std::flat_multiset<int>;
+
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<int>>);
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<short>>);
+static_assert(!std::is_constructible_v<Set, std::from_range_t, RangeOf<std::pair<int, int>>>);
+
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<int>, std::less<int>>);
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<short>, std::less<int>>);
+static_assert(!std::is_constructible_v<Set, std::from_range_t, RangeOf<std::pair<int, int>>, std::less<int>>);
+
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<int>, std::allocator<int>>);
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<short>, std::allocator<int>>);
+static_assert(!std::is_constructible_v<Set, std::from_range_t, RangeOf<std::pair<int, int>>, std::allocator<int>>);
+
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<int>, std::less<int>, std::allocator<int>>);
+static_assert(std::is_constructible_v<Set, std::from_range_t, RangeOf<int>, std::less<int>, std::allocator<int>>);
+static_assert(
+    !std::
+        is_constructible_v<Set, std::from_range_t, RangeOf<std::pair<int, int>>, std::less<int>, std::allocator<int>>);
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    static_assert(std::is_constructible_v<M1, std::from_range_t, M1, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::from_range_t, M2, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::from_range_t, M1, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::from_range_t, M2, const A1&>);
+
+    static_assert(std::is_constructible_v<M1, std::from_range_t, M1, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::from_range_t, M2, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::from_range_t, M1, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::from_range_t, M2, const C&, const A1&>);
+  }
+
+  int ar[]       = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+  int expected[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
+  {
+    // flat_multiset(from_range_t, R&&)
+    // input_range && !common
+    using M    = std::flat_multiset<int>;
+    using Iter = cpp20_input_iterator<const int*>;
+    using Sent = sentinel_wrapper<Iter>;
+    using R    = std::ranges::subrange<Iter, Sent>;
+    auto m     = M(std::from_range, R(Iter(ar), Sent(Iter(ar + 9))));
+    assert(std::ranges::equal(m, expected));
+
+    // explicit(false)
+    M m2 = {std::from_range, R(Iter(ar), Sent(Iter(ar + 9)))};
+    assert(m2 == m);
+  }
+  {
+    // flat_multiset(from_range_t, R&&)
+    // greater
+    using M    = std::flat_multiset<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+    using Iter = cpp20_input_iterator<const int*>;
+    using Sent = sentinel_wrapper<Iter>;
+    using R    = std::ranges::subrange<Iter, Sent>;
+    auto m     = M(std::from_range, R(Iter(ar), Sent(Iter(ar + 9))));
+    assert(std::ranges::equal(m, std::deque<int, min_allocator<int>>{3, 3, 3, 2, 2, 2, 1, 1, 1}));
+  }
+  {
+    // flat_multiset(from_range_t, R&&)
+    // contiguous range
+    using M = std::flat_multiset<int>;
+    using R = std::ranges::subrange<const int*>;
+    auto m  = M(std::from_range, R(ar, ar + 9));
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    // flat_multiset(from_range_t, R&&, const key_compare&)
+    using C = test_less<int>;
+    using M = std::flat_multiset<int, C, std::vector<int>>;
+    using R = std::ranges::subrange<const int*>;
+    auto m  = M(std::from_range, R(ar, ar + 9), C(3));
+    assert(std::ranges::equal(m, expected));
+    assert(m.key_comp() == C(3));
+
+    // explicit(false)
+    M m2 = {std::from_range, R(ar, ar + 9), C(3)};
+    assert(m2 == m);
+    assert(m2.key_comp() == C(3));
+  }
+  {
+    // flat_multiset(from_range_t, R&&, const Allocator&)
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, std::less<int>, std::vector<int, A1>>;
+    using R  = std::ranges::subrange<const int*>;
+    auto m   = M(std::from_range, R(ar, ar + 9), A1(5));
+    assert(std::ranges::equal(m, expected));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(from_range_t, R&&, const Allocator&)
+    // explicit(false)
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, std::less<int>, std::deque<int, A1>>;
+    using R  = std::ranges::subrange<const int*>;
+    M m      = {std::from_range, R(ar, ar + 9), A1(5)}; // implicit ctor
+    assert(std::ranges::equal(m, expected));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(from_range_t, R&&, const key_compare&, const Allocator&)
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, C, std::vector<int, A1>>;
+    using R  = std::ranges::subrange<const int*>;
+    auto m   = M(std::from_range, R(ar, ar + 9), C(3), A1(5));
+    assert(std::ranges::equal(m, expected));
+    assert(m.key_comp() == C(3));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(from_range_t, R&&, const key_compare&, const Allocator&)
+    // explicit(false)
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, std::less<int>, std::deque<int, A1>>;
+    using R  = std::ranges::subrange<const int*>;
+    M m      = {std::from_range, R(ar, ar + 9), {}, A1(5)}; // implicit ctor
+    assert(std::ranges::equal(m, expected));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_container.pass.cpp
new file mode 100644
index 0000000000000..76759be7da8e3
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_container.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset(sorted_equivalent_t, container_type key_cont, const key_compare& comp = key_compare());
+//
+// template<class Alloc>
+//   flat_multiset(sorted_equivalent_t, const container_type& key_cont, const Alloc& a);
+// template<class Alloc>
+//   flat_multiset(sorted_equivalent_t, const container_type& key_cont,
+//            const key_compare& comp, const Alloc& a);
+
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "min_allocator.h"
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    static_assert(std::is_constructible_v<M1, std::sorted_equivalent_t, const V1&, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::sorted_equivalent_t, const V2&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::sorted_equivalent_t, const V1&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::sorted_equivalent_t, const V2&, const A1&>);
+
+    static_assert(std::is_constructible_v<M1, std::sorted_equivalent_t, const V1&, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::sorted_equivalent_t, const V2&, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::sorted_equivalent_t, const V1&, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::sorted_equivalent_t, const V2&, const C&, const A1&>);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, container_type)
+    using M             = std::flat_multiset<int>;
+    std::vector<int> ks = {1, 2, 2, 4, 10};
+    auto ks2            = ks;
+
+    auto m = M(std::sorted_equivalent, ks);
+    assert((m == M{1, 2, 2, 4, 10}));
+    m = M(std::sorted_equivalent, std::move(ks));
+    assert(ks.empty()); // it was moved-from
+    assert((m == M{1, 2, 2, 4, 10}));
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, std::move(ks2)};
+    assert(m == m2);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, container_type)
+    // non-default container, comparator and allocator type
+    using Ks = std::deque<int, min_allocator<int>>;
+    using M  = std::flat_multiset<int, std::greater<int>, Ks>;
+    Ks ks    = {10, 4, 4, 2, 1};
+    auto m   = M(std::sorted_equivalent, ks);
+    assert((m == M{1, 2, 4, 4, 10}));
+    m = M(std::sorted_equivalent, std::move(ks));
+    assert(ks.empty()); // it was moved-from
+    assert((m == M{1, 2, 4, 4, 10}));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, container_type)
+    // allocator copied into the containers
+    using A = test_allocator<int>;
+    using M = std::flat_multiset<int, std::less<int>, std::deque<int, A>>;
+    auto ks = std::deque<int, A>({1, 2, 2, 4, 10}, A(4));
+    auto m  = M(std::sorted_equivalent, std::move(ks));
+    assert(ks.empty()); // it was moved-from
+    assert((m == M{1, 2, 2, 4, 10}));
+    assert(std::move(m).extract().get_allocator() == A(4));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, container_type ,  key_compare)
+    using C             = test_less<int>;
+    using M             = std::flat_multiset<int, C>;
+    std::vector<int> ks = {1, 2, 2, 4, 10};
+
+    auto m = M(std::sorted_equivalent, ks, C(4));
+    assert((m == M{1, 2, 2, 4, 10}));
+    assert(m.key_comp() == C(4));
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, ks, C(4)};
+    assert(m2 == m);
+    assert(m2.key_comp() == C(4));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, container_type , key_compare, const Allocator&)
+    using C                = test_less<int>;
+    using A                = test_allocator<int>;
+    using M                = std::flat_multiset<int, C, std::vector<int, A>>;
+    std::vector<int, A> ks = {1, 2, 2, 4, 10};
+    auto m                 = M(std::sorted_equivalent, ks, C(4), A(5));
+    assert((m == M{1, 2, 2, 4, 10}));
+    assert(m.key_comp() == C(4));
+    assert(M(m).extract().get_allocator() == A(5));
+
+    // explicit(false)
+    M m2 = {ks, C(4), A(5)};
+    assert(m2 == m);
+    assert(m2.key_comp() == C(4));
+    assert(std::move(m2).extract().get_allocator() == A(5));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, container_type , const Allocator&)
+    using A = test_allocator<int>;
+    using M = std::flat_multiset<int, std::less<int>, std::deque<int, A>>;
+    auto ks = std::deque<int, A>({1, 2, 2, 4, 10}, A(4));
+    auto m  = M(std::sorted_equivalent, ks, A(6)); // replaces the allocators
+    assert(!ks.empty());                           // it was an lvalue above
+    assert((m == M{1, 2, 2, 4, 10}));
+    assert(M(m).extract().get_allocator() == A(6));
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, ks, A(6)};
+    assert(m2 == m);
+    assert(std::move(m2).extract().get_allocator() == A(6));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..955662dd233ef
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_initializer_list.pass.cpp
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template <class InputIterator>
+//   flat_multiset(sorted_equivalent_t s, initializer_list<value_type> il,
+//            const key_compare& comp = key_compare())
+// template<class Alloc>
+//   flat_multiset(sorted_equivalent_t, initializer_list<value_type> il, const Alloc& a);
+// template<class Alloc>
+//   flat_multiset(sorted_equivalent_t, initializer_list<value_type> il,
+//            const key_compare& comp, const Alloc& a);
+
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+
+template <class T>
+std::initializer_list<T> il = {1, 2, 4, 4, 5};
+
+void test() {
+  const auto il1 = il<int>;
+  const auto il2 = il<short>;
+
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using A2 = other_allocator<int>;
+    using V1 = std::vector<int, A1>;
+    using V2 = std::vector<int, A2>;
+    using M1 = std::flat_multiset<int, C, V1>;
+    using M2 = std::flat_multiset<int, C, V2>;
+    using IL = std::initializer_list<int>;
+
+    static_assert(std::is_constructible_v<M1, std::sorted_equivalent_t, IL, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::sorted_equivalent_t, IL, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::sorted_equivalent_t, IL, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::sorted_equivalent_t, IL, const A1&>);
+
+    static_assert(std::is_constructible_v<M1, std::sorted_equivalent_t, IL, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::sorted_equivalent_t, IL, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::sorted_equivalent_t, IL, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::sorted_equivalent_t, IL, const C&, const A1&>);
+  }
+  {
+    // initializer_list<value_type> needs to match exactly
+    using M = std::flat_multiset<int>;
+    using C = typename M::key_compare;
+    static_assert(std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<int>>);
+    static_assert(std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<int>, C>);
+    static_assert(
+        std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<int>, C, std::allocator<int>>);
+    static_assert(
+        std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<int>, std::allocator<int>>);
+    static_assert(!std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>>);
+    static_assert(!std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>, C>);
+    static_assert(
+        !std::
+            is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>, C, std::allocator<int>>);
+    static_assert(
+        !std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>, std::allocator<int>>);
+    static_assert(!std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>>);
+    static_assert(!std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>, C>);
+    static_assert(
+        !std::
+            is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>, C, std::allocator<int>>);
+    static_assert(
+        !std::is_constructible_v<M, std::sorted_equivalent_t, std::initializer_list<const int>, std::allocator<int>>);
+  }
+
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type>);
+    using M       = std::flat_multiset<int>;
+    auto m        = M(std::sorted_equivalent, il1);
+    auto expected = M{1, 2, 4, 4, 5};
+    assert(m == expected);
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, il1};
+    assert(m2 == m);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type>, const key_compare&);
+    using M = std::flat_multiset<int, std::function<bool(int, int)>>;
+    auto m  = M(std::sorted_equivalent, il1, std::less<int>());
+    assert(m == M({1, 2, 4, 4, 5}, std::less<>()));
+    assert(m.key_comp()(1, 2) == true);
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, il1, std::less<int>()};
+    assert(m2 == m);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type>, const key_compare&);
+    // greater
+    using M = std::flat_multiset<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+    std::initializer_list<int> il4{5, 4, 4, 2, 1};
+    auto m = M(std::sorted_equivalent, il4, std::greater<int>());
+    assert((m == M{5, 4, 4, 2, 1}));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type>,  const Allocator&)
+    using A1      = test_allocator<short>;
+    using M       = std::flat_multiset<short, std::less<int>, std::deque<short, A1>>;
+    auto m        = M(std::sorted_equivalent, il2, A1(5));
+    auto expected = M{1, 2, 4, 4, 5};
+    assert(m == expected);
+    assert(M(m).extract().get_allocator() == A1(5));
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, il2, A1(5)};
+    assert(m2 == m);
+    assert(std::move(m2).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type>, const key_compare&, const Allocator&);
+    using C  = test_less<int>;
+    using A1 = test_allocator<short>;
+    using M  = std::flat_multiset<short, C, std::vector<short, A1>>;
+    auto m   = M(std::sorted_equivalent, il2, C(3), A1(5));
+    assert((m == M{1, 2, 4, 4, 5}));
+    assert(m.key_comp() == C(3));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, initializer_list<value_type>, const key_compare&, const Allocator&);
+    // explicit(false)
+    using A1 = test_allocator<short>;
+    using M  = std::flat_multiset<short, std::less<int>, std::deque<short, A1>>;
+    M m      = {std::sorted_equivalent, il2, {}, A1(5)}; // implicit ctor
+    assert((m == M{1, 2, 4, 4, 5}));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..9ebe45d71d667
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/sorted_iter_iter.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template <class InputIterator>
+//   flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last, const key_compare& comp = key_compare());
+// template<class InputIterator, class Alloc>
+//   flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last, const Alloc& a);
+// template<class InputIterator, class Allocator>
+//   flat_multiset(sorted_equivalent_t, InputIterator first, InputIterator last, const key_compare& comp, const Allocator& a);
+
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "../../../test_compare.h"
+
+void test() {
+  {
+    // The constructors in this subclause shall not participate in overload
+    // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+    using C     = test_less<int>;
+    using A1    = test_allocator<int>;
+    using A2    = other_allocator<int>;
+    using V1    = std::vector<int, A1>;
+    using V2    = std::vector<int, A2>;
+    using M1    = std::flat_multiset<int, C, V1>;
+    using M2    = std::flat_multiset<int, C, V2>;
+    using Iter1 = typename M1::iterator;
+    using Iter2 = typename M2::iterator;
+    static_assert(std::is_constructible_v<M1, std::sorted_equivalent_t, Iter1, Iter1, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::sorted_equivalent_t, Iter2, Iter2, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::sorted_equivalent_t, Iter1, Iter1, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::sorted_equivalent_t, Iter2, Iter2, const A1&>);
+
+    static_assert(std::is_constructible_v<M1, std::sorted_equivalent_t, Iter1, Iter1, const C&, const A1&>);
+    static_assert(std::is_constructible_v<M2, std::sorted_equivalent_t, Iter2, Iter2, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M1, std::sorted_equivalent_t, Iter1, Iter1, const C&, const A2&>);
+    static_assert(!std::is_constructible_v<M2, std::sorted_equivalent_t, Iter2, Iter2, const C&, const A1&>);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator);
+    // cpp17_input_iterator
+    using M  = std::flat_multiset<int>;
+    int ar[] = {1, 2, 2, 4, 5};
+    auto m = M(std::sorted_equivalent, cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 5));
+    auto expected = M{1, 2, 2, 4, 5};
+    assert(m == expected);
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 5)};
+    assert(m2 == m);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator);
+    // contiguous iterator
+    using C       = test_less<int>;
+    using M       = std::flat_multiset<int, C, std::vector<int, min_allocator<int>>>;
+    int ar[]      = {1, 2, 4, 4, 5};
+    auto m        = M(std::sorted_equivalent, ar, ar + 5);
+    auto expected = M{1, 2, 4, 4, 5};
+    assert(m == expected);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, const key_compare&);
+    // cpp_17_input_iterator
+    using M  = std::flat_multiset<int, std::function<bool(int, int)>>;
+    int ar[] = {1, 2, 4, 4, 5};
+    auto m   = M(std::sorted_equivalent,
+               cpp17_input_iterator<const int*>(ar),
+               cpp17_input_iterator<const int*>(ar + 5),
+               std::less<int>());
+    assert(m == M({1, 2, 4, 4, 5}, std::less<>()));
+    assert(m.key_comp()(1, 2) == true);
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent,
+            cpp17_input_iterator<const int*>(ar),
+            cpp17_input_iterator<const int*>(ar + 5),
+            std::less<int>()};
+    assert(m2 == m);
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, const key_compare&);
+    // greater
+    using M  = std::flat_multiset<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+    int ar[] = {5, 4, 4, 2, 1};
+    auto m   = M(std::sorted_equivalent,
+               cpp17_input_iterator<const int*>(ar),
+               cpp17_input_iterator<const int*>(ar + 5),
+               std::greater<int>());
+    assert((m == M{5, 4, 4, 2, 1}));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, const key_compare&);
+    // contiguous iterator
+    using C   = test_less<int>;
+    using M   = std::flat_multiset<int, C, std::vector<int, min_allocator<int>>>;
+    int ar[1] = {42};
+    auto m    = M(std::sorted_equivalent, ar, ar, C(5));
+    assert(m.empty());
+    assert(m.key_comp() == C(5));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator , InputIterator, const Allocator&)
+    using A1      = test_allocator<int>;
+    using M       = std::flat_multiset<int, std::less<int>, std::vector<int, A1>>;
+    int ar[]      = {1, 2, 4, 4, 5};
+    auto m        = M(std::sorted_equivalent, ar, ar + 5, A1(5));
+    auto expected = M{1, 2, 4, 4, 5};
+    assert(m == expected);
+    assert(M(m).extract().get_allocator() == A1(5));
+
+    // explicit(false)
+    M m2 = {std::sorted_equivalent, ar, ar + 5, A1(5)};
+    assert(m2 == m);
+    assert(std::move(m2).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, const key_compare&, const Allocator&);
+    using C  = test_less<int>;
+    using A1 = test_allocator<int>;
+    using M  = std::flat_multiset<int, C, std::deque<int, A1>>;
+    int ar[] = {1, 2, 4, 4, 5};
+    auto m   = M(std::sorted_equivalent, ar, ar + 5, C(3), A1(5));
+    assert((m == M{1, 2, 4, 4, 5}));
+    assert(m.key_comp() == C(3));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+  {
+    // flat_multiset(sorted_equivalent_t, InputIterator, InputIterator, const key_compare&, const Allocator&);
+    // explicit(false)
+    using A1 = test_allocator<short>;
+    using M  = std::flat_multiset<short, std::less<int>, std::deque<short, A1>>;
+    int ar[] = {1, 2, 4, 4, 5};
+    M m      = {std::sorted_equivalent, ar, ar + 5, {}, A1(5)}; // implicit ctor
+    assert((m == M{1, 2, 4, 4, 5}));
+    assert(std::move(m).extract().get_allocator() == A1(5));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if.pass.cpp
new file mode 100644
index 0000000000000..21f3c918dec0d
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class Key, class Compare, class KeyContainer, class Predicate>
+//   typename flat_multiset<Key, Compare, KeyContainer>::size_type
+//   erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred);
+
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <initializer_list>
+#include <vector>
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+// Verify that `flat_multiset` (like `set`) does NOT support std::erase.
+//
+template <class S>
+concept HasStdErase = requires(S& s, typename S::value_type x) { std::erase(s, x); };
+static_assert(HasStdErase<std::vector<int>>);
+static_assert(!HasStdErase<std::flat_multiset<int>>);
+
+template <class M>
+M make(std::initializer_list<int> vals) {
+  M ret;
+  for (int v : vals)
+    ret.emplace(v);
+  return ret;
+}
+
+template <class M, class Pred>
+void test0(
+    std::initializer_list<int> vals, Pred p, std::initializer_list<int> expected, std::size_t expected_erased_count) {
+  M s = make<M>(vals);
+  ASSERT_SAME_TYPE(typename M::size_type, decltype(std::erase_if(s, p)));
+  assert(expected_erased_count == std::erase_if(s, p));
+  assert(s == make<M>(expected));
+}
+
+struct NotBool {
+  bool b;
+  explicit operator bool() const { return b; }
+};
+
+template <class S>
+void test_one() {
+  // Test all the plausible signatures for this predicate.
+  auto is1        = [](typename S::const_reference v) { return v == 1; };
+  auto is2        = [](typename S::value_type v) { return v == 2; };
+  auto is3        = [](const typename S::value_type& v) { return v == 3; };
+  auto is4        = [](auto v) { return v == 4; };
+  auto True       = [](const auto&) { return true; };
+  auto False      = [](auto&&) { return false; };
+  auto nonBoolIs1 = [](const auto& v) { return NotBool{v == 1}; };
+
+  test0<S>({}, is1, {}, 0);
+
+  test0<S>({1}, is1, {}, 1);
+  test0<S>({1, 1, 1}, is1, {}, 3);
+  test0<S>({1}, is2, {1}, 0);
+  test0<S>({1, 1, 1}, is2, {1, 1, 1}, 0);
+
+  test0<S>({1, 2}, is1, {2}, 1);
+  test0<S>({1, 1, 1, 2, 2}, is1, {2, 2}, 3);
+  test0<S>({1, 2}, is2, {1}, 1);
+  test0<S>({1, 1, 1, 2, 2}, is2, {1, 1, 1}, 2);
+  test0<S>({1, 2}, is3, {1, 2}, 0);
+  test0<S>({1, 1, 1, 2, 2}, is3, {1, 1, 1, 2, 2}, 0);
+
+  test0<S>({1, 2, 3}, is1, {2, 3}, 1);
+  test0<S>({1, 1, 2, 2, 3, 3}, is1, {2, 2, 3, 3}, 2);
+  test0<S>({1, 2, 3}, is2, {1, 3}, 1);
+  test0<S>({1, 1, 2, 2, 3, 3}, is2, {1, 1, 3, 3}, 2);
+  test0<S>({1, 2, 3}, is3, {1, 2}, 1);
+  test0<S>({1, 1, 2, 2, 3, 3}, is3, {1, 1, 2, 2}, 2);
+  test0<S>({1, 2, 3}, is4, {1, 2, 3}, 0);
+  test0<S>({1, 1, 2, 2, 3, 3}, is4, {1, 1, 2, 2, 3, 3}, 0);
+
+  test0<S>({1, 2, 3}, True, {}, 3);
+  test0<S>({1, 2, 2, 3, 3, 3}, True, {}, 6);
+  test0<S>({1, 2, 3}, False, {1, 2, 3}, 0);
+  test0<S>({1, 2, 2, 3, 3, 3}, False, {1, 2, 2, 3, 3, 3}, 0);
+
+  test0<S>({1, 2, 3}, nonBoolIs1, {2, 3}, 1);
+  test0<S>({1, 1, 2, 2, 3}, nonBoolIs1, {2, 2, 3}, 2);
+}
+
+void test() {
+  test_one<std::flat_multiset<int>>();
+  test_one<std::flat_multiset<int, std::less<int>, std::vector<int, min_allocator<int>>>>();
+  test_one<std::flat_multiset<int, std::greater<int>, std::vector<int, test_allocator<int>>>>();
+  test_one<std::flat_multiset<int, std::less<int>, std::deque<int, min_allocator<int>>>>();
+  test_one<std::flat_multiset<int, std::greater<int>, std::deque<int, test_allocator<int>>>>();
+  test_one<std::flat_multiset<long>>();
+  test_one<std::flat_multiset<double>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if_exceptions.pass.cpp
new file mode 100644
index 0000000000000..64dc110006a5a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.erasure/erase_if_exceptions.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: no-exceptions
+
+// <flat_set>
+
+// template<class Key, class Compare, class KeyContainer, class Predicate>
+//   typename flat_multiset<Key, Compare, KeyContainer>::size_type
+//   erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred);
+// If any member function in [flat.set.defn] exits via an exception, the invariant is restored.
+// (This is not a member function, but let's respect the invariant anyway.)
+
+#include <algorithm>
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+#include <vector>
+
+#include "../helpers.h"
+#include "test_macros.h"
+
+struct Counter {
+  int c1, c2, throws;
+  void tick() {
+    c1 -= 1;
+    if (c1 == 0) {
+      c1 = c2;
+      throws += 1;
+      throw 42;
+    }
+  }
+};
+Counter g_counter = {0, 0, 0};
+
+struct ThrowingAssignment {
+  ThrowingAssignment(int i) : i_(i) {}
+  ThrowingAssignment(const ThrowingAssignment&) = default;
+  ThrowingAssignment& operator=(const ThrowingAssignment& rhs) {
+    g_counter.tick();
+    i_ = rhs.i_;
+    g_counter.tick();
+    return *this;
+  }
+  operator int() const { return i_; }
+  int i_;
+};
+
+struct ThrowingComparator {
+  bool operator()(const ThrowingAssignment& a, const ThrowingAssignment& b) const {
+    g_counter.tick();
+    return a.i_ < b.i_;
+  }
+};
+
+struct ErasurePredicate {
+  bool operator()(const auto& x) const { return (3 <= x && x <= 5); }
+};
+
+void test() {
+  {
+    using M = std::flat_multiset<ThrowingAssignment, ThrowingComparator>;
+    for (int first_throw = 1; first_throw < 99; ++first_throw) {
+      for (int second_throw = 1; second_throw < 99; ++second_throw) {
+        g_counter = {0, 0, 0};
+        M m       = M({1, 1, 2, 3, 3, 3, 4, 5, 6, 7, 8});
+        try {
+          g_counter = {first_throw, second_throw, 0};
+          auto n    = std::erase_if(m, ErasurePredicate());
+          assert(n == 5);
+          // If it didn't throw at all, we're done.
+          g_counter = {0, 0, 0};
+          assert((m == M{1, 1, 2, 6, 7, 8}));
+          first_throw = 99; // "done"
+          break;
+        } catch (int ex) {
+          assert(ex == 42);
+          check_invariant(m);
+          LIBCPP_ASSERT(m.empty());
+          if (g_counter.throws == 1) {
+            // We reached the first throw but not the second throw.
+            break;
+          }
+        }
+      }
+    }
+  }
+
+  {
+    using M = std::flat_multiset<ThrowingAssignment, ThrowingComparator, std::deque<ThrowingAssignment>>;
+    for (int first_throw = 1; first_throw < 99; ++first_throw) {
+      for (int second_throw = 1; second_throw < 99; ++second_throw) {
+        g_counter                                = {0, 0, 0};
+        std::deque<ThrowingAssignment> container = {5, 6, 7, 8};
+        container.insert(container.begin(), {1, 2, 3, 4});
+        M m = M(std::move(container));
+        try {
+          g_counter = {first_throw, second_throw, 0};
+          auto n    = std::erase_if(m, ErasurePredicate());
+          assert(n == 3);
+          // If it didn't throw at all, we're done.
+          g_counter = {0, 0, 0};
+          assert((m == M{1, 2, 6, 7, 8}));
+          first_throw = 99; // "done"
+          break;
+        } catch (int ex) {
+          assert(ex == 42);
+          check_invariant(m);
+          LIBCPP_ASSERT(m.empty());
+          if (g_counter.throws == 1) {
+            // We reached the first throw but not the second throw.
+            break;
+          }
+        }
+      }
+    }
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator.pass.cpp
new file mode 100644
index 0000000000000..809f03df47977
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+//       iterator begin()   noexcept;
+// const_iterator begin()   const noexcept
+//       iterator end()     noexcept;
+// const_iterator end()     const noexcept;
+//
+// const_iterator cbegin()  const noexcept;
+// const_iterator cend()    const noexcept;
+
+#include <cassert>
+#include <cstddef>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+
+  M m            = {1, 2, 3, 4, 1, 4, 2, 3, 1};
+  int expected[] = {1, 1, 1, 2, 2, 3, 3, 4, 4};
+  const M& cm    = m;
+  ASSERT_SAME_TYPE(decltype(m.begin()), typename M::iterator);
+  ASSERT_SAME_TYPE(decltype(m.cbegin()), typename M::const_iterator);
+  ASSERT_SAME_TYPE(decltype(cm.begin()), typename M::const_iterator);
+  ASSERT_SAME_TYPE(decltype(m.end()), typename M::iterator);
+  ASSERT_SAME_TYPE(decltype(m.cend()), typename M::const_iterator);
+  ASSERT_SAME_TYPE(decltype(cm.end()), typename M::const_iterator);
+  static_assert(noexcept(m.begin()));
+  static_assert(noexcept(cm.begin()));
+  static_assert(noexcept(m.cbegin()));
+  static_assert(noexcept(m.end()));
+  static_assert(noexcept(cm.end()));
+  static_assert(noexcept(m.cend()));
+  assert(m.size() == 9);
+  assert(std::distance(m.begin(), m.end()) == 9);
+  assert(std::distance(cm.begin(), cm.end()) == 9);
+  assert(std::distance(m.cbegin(), m.cend()) == 9);
+  typename M::iterator i;                   // default-construct
+  i                            = m.begin(); // move-assignment
+  typename M::const_iterator k = i;         // converting constructor
+  assert(i == k);                           // comparison
+  for (int j = 0; j < 9; ++j, ++i) {        // pre-increment
+    assert(*i == expected[j]);              // operator*
+  }
+  assert(i == m.end());
+  for (int j = 8; j >= 0; --j) {
+    --i; // pre-decrement
+    assert((*i) == expected[j]);
+  }
+  assert(i == m.begin());
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+
+  {
+    // N3644 testing
+    using C = std::flat_multiset<int>;
+    C::iterator ii1{}, ii2{};
+    C::iterator ii4 = ii1;
+    C::const_iterator cii{};
+    assert(ii1 == ii2);
+    assert(ii1 == ii4);
+    assert(!(ii1 != ii2));
+
+    assert((ii1 == cii));
+    assert((cii == ii1));
+    assert(!(ii1 != cii));
+    assert(!(cii != ii1));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_comparison.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_comparison.pass.cpp
new file mode 100644
index 0000000000000..d26e3446072ef
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_comparison.pass.cpp
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// flat_multiset iterators should be C++20 random access iterators
+
+#include <compare>
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using KI  = typename KeyContainer::iterator;
+  using I   = M::iterator;
+  using CI  = M::const_iterator;
+  using RI  = M::reverse_iterator;
+  using CRI = M::const_reverse_iterator;
+
+  static_assert(std::equality_comparable<I>);
+  static_assert(std::equality_comparable<CI>);
+  static_assert(std::equality_comparable<RI>);
+  static_assert(std::equality_comparable<CRI>);
+
+  static_assert(std::totally_ordered<I>);
+  static_assert(std::totally_ordered<CI>);
+  static_assert(std::totally_ordered<RI>);
+  static_assert(std::totally_ordered<CRI>);
+
+  M m = {1, 1, 3, 4};
+
+  I i1 = m.begin();
+  I i2 = m.begin() + 1;
+
+  assert(i1 == i1);
+  assert(!(i1 != i1));
+  assert(i1 != i2);
+  assert(!(i1 == i2));
+  assert(i1 < i2);
+  assert(!(i1 < i1));
+  assert(i1 <= i1);
+  assert(i1 <= i2);
+  assert(!(i2 <= i1));
+  assert(i2 > i1);
+  assert(!(i2 > i2));
+  assert(i2 >= i1);
+  assert(i2 >= i2);
+  assert(!(i1 >= i2));
+
+  CI ci1 = m.cbegin();
+  CI ci2 = m.cbegin() + 1;
+  assert(ci1 == ci1);
+  assert(!(ci1 != ci1));
+  assert(ci1 != ci2);
+  assert(!(ci1 == ci2));
+  assert(ci1 < ci2);
+  assert(!(ci1 < ci1));
+  assert(ci1 <= ci1);
+  assert(ci1 <= ci2);
+  assert(!(ci2 <= ci1));
+  assert(ci2 > ci1);
+  assert(!(ci2 > ci2));
+  assert(ci2 >= ci1);
+  assert(ci2 >= ci2);
+  assert(!(ci1 >= ci2));
+
+  RI ri1 = m.rbegin();
+  RI ri2 = m.rbegin() + 1;
+  assert(ri1 == ri1);
+  assert(!(ri1 != ri1));
+  assert(ri1 != ri2);
+  assert(!(ri1 == ri2));
+  assert(ri1 < ri2);
+  assert(!(ri1 < ri1));
+  assert(ri1 <= ri1);
+  assert(ri1 <= ri2);
+  assert(!(ri2 <= ri1));
+  assert(ri2 > ri1);
+  assert(!(ri2 > ri2));
+  assert(ri2 >= ri1);
+  assert(ri2 >= ri2);
+  assert(!(ri1 >= ri2));
+
+  CRI cri1 = m.crbegin();
+  CRI cri2 = m.crbegin() + 1;
+  assert(cri1 == cri1);
+  assert(!(cri1 != cri1));
+  assert(cri1 != cri2);
+  assert(!(cri1 == cri2));
+  assert(cri1 < cri2);
+  assert(!(cri1 < cri1));
+  assert(cri1 <= cri1);
+  assert(cri1 <= cri2);
+  assert(!(cri2 <= cri1));
+  assert(cri2 > cri1);
+  assert(!(cri2 > cri2));
+  assert(cri2 >= cri1);
+  assert(cri2 >= cri2);
+  assert(!(cri1 >= cri2));
+
+  if constexpr (std::three_way_comparable<KI>) {
+    static_assert(std::three_way_comparable<I>); // ...of course the wrapped iterators still support <=>.
+    static_assert(std::three_way_comparable<CI>);
+    static_assert(std::three_way_comparable<RI>);
+    static_assert(std::three_way_comparable<CRI>);
+    static_assert(std::same_as<decltype(I() <=> I()), std::strong_ordering>);
+    static_assert(std::same_as<decltype(I() <=> CI()), std::strong_ordering>);
+    static_assert(std::same_as<decltype(CI() <=> CI()), std::strong_ordering>);
+    static_assert(std::same_as<decltype(RI() <=> RI()), std::strong_ordering>);
+    static_assert(std::same_as<decltype(RI() <=> CRI()), std::strong_ordering>);
+    static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);
+
+    assert(i1 <=> i1 == std::strong_ordering::equivalent);
+    assert(i1 <=> i2 == std::strong_ordering::less);
+    assert(i2 <=> i1 == std::strong_ordering::greater);
+
+    assert(ci1 <=> ci1 == std::strong_ordering::equivalent);
+    assert(ci1 <=> ci2 == std::strong_ordering::less);
+    assert(ci2 <=> ci1 == std::strong_ordering::greater);
+
+    assert(ri1 <=> ri1 == std::strong_ordering::equivalent);
+    assert(ri1 <=> ri2 == std::strong_ordering::less);
+    assert(ri2 <=> ri1 == std::strong_ordering::greater);
+
+    assert(cri1 <=> cri1 == std::strong_ordering::equivalent);
+    assert(cri1 <=> cri2 == std::strong_ordering::less);
+    assert(cri2 <=> cri1 == std::strong_ordering::greater);
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_concept_conformance.compile.pass.cpp
new file mode 100644
index 0000000000000..0745b8f2433bc
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/iterator_concept_conformance.compile.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// iterator, const_iterator, reverse_iterator, const_reverse_iterator
+
+#include <flat_set>
+#include <deque>
+#include <functional>
+#include <iterator>
+#include <string>
+#include <vector>
+#include <type_traits>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test() {
+  using Key = typename KeyContainer::value_type;
+  using C   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using I   = C::iterator;
+  using CI  = C::const_iterator;
+  using RI  = C::reverse_iterator;
+  using CRI = C::const_reverse_iterator;
+  static_assert(std::random_access_iterator<I>);
+  static_assert(std::random_access_iterator<CI>);
+  static_assert(std::random_access_iterator<RI>);
+  static_assert(std::random_access_iterator<CRI>);
+  static_assert(!std::contiguous_iterator<RI>);
+  static_assert(!std::contiguous_iterator<CRI>);
+  static_assert(!std::indirectly_writable<I, std::pair<int, char>>);
+  static_assert(!std::indirectly_writable<CI, std::pair<int, char>>);
+  static_assert(!std::indirectly_writable<RI, std::pair<int, char>>);
+  static_assert(!std::indirectly_writable<CRI, std::pair<int, char>>);
+  static_assert(std::sentinel_for<I, I>);
+  static_assert(std::sentinel_for<I, CI>);
+  static_assert(!std::sentinel_for<I, RI>);
+  static_assert(!std::sentinel_for<I, CRI>);
+  static_assert(std::sentinel_for<CI, I>);
+  static_assert(std::sentinel_for<CI, CI>);
+  static_assert(!std::sentinel_for<CI, RI>);
+  static_assert(!std::sentinel_for<CI, CRI>);
+  static_assert(!std::sentinel_for<RI, I>);
+  static_assert(!std::sentinel_for<RI, CI>);
+  static_assert(std::sentinel_for<RI, RI>);
+  static_assert(std::sentinel_for<RI, CRI>);
+  static_assert(!std::sentinel_for<CRI, I>);
+  static_assert(!std::sentinel_for<CRI, CI>);
+  static_assert(std::sentinel_for<CRI, RI>);
+  static_assert(std::sentinel_for<CRI, CRI>);
+  static_assert(std::indirectly_movable_storable<I, Key*>);
+  static_assert(std::indirectly_movable_storable<CI, Key*>);
+  static_assert(std::indirectly_movable_storable<RI, Key*>);
+  static_assert(std::indirectly_movable_storable<CRI, Key*>);
+
+  static_assert(std::is_same_v<typename std::iterator_traits<I>::iterator_category, std::random_access_iterator_tag>);
+  static_assert(std::is_same_v<typename std::iterator_traits<CI>::iterator_category, std::random_access_iterator_tag>);
+  static_assert(std::is_same_v<typename std::iterator_traits<RI>::iterator_category, std::random_access_iterator_tag>);
+  static_assert(std::is_same_v<typename std::iterator_traits<CRI>::iterator_category, std::random_access_iterator_tag>);
+}
+
+void test() {
+  test<std::vector<int>>();
+  test<std::deque<int>>();
+  test<MinSequenceContainer<int>>();
+  test<std::vector<int, min_allocator<int>>>();
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/range_concept_conformance.compile.pass.cpp
new file mode 100644
index 0000000000000..ccb7b94e0b3f5
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/range_concept_conformance.compile.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <ranges>
+#include <string>
+#include <vector>
+#include "MinSequenceContainer.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test() {
+  {
+    using Key = typename KeyContainer::value_type;
+    using C   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+
+    static_assert(std::same_as<std::ranges::iterator_t<C>, typename C::iterator>);
+    static_assert(std::ranges::random_access_range<C>);
+    static_assert(std::ranges::common_range<C>);
+    static_assert(std::ranges::input_range<C>);
+    static_assert(!std::ranges::view<C>);
+    static_assert(std::ranges::sized_range<C>);
+    static_assert(!std::ranges::borrowed_range<C>);
+    static_assert(std::ranges::viewable_range<C>);
+
+    static_assert(std::same_as<std::ranges::iterator_t<const C>, typename C::const_iterator>);
+    static_assert(std::ranges::random_access_range<const C>);
+    static_assert(std::ranges::common_range<const C>);
+    static_assert(std::ranges::input_range<const C>);
+    static_assert(!std::ranges::view<const C>);
+    static_assert(std::ranges::sized_range<const C>);
+    static_assert(!std::ranges::borrowed_range<const C>);
+    static_assert(!std::ranges::viewable_range<const C>);
+  }
+}
+
+void test() {
+  test<std::vector<int>>();
+  test<std::deque<int>>();
+  test<MinSequenceContainer<int>>();
+  test<std::vector<int, min_allocator<int>>>();
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/reverse_iterator.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/reverse_iterator.pass.cpp
new file mode 100644
index 0000000000000..9d443ef8784e2
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.iterators/reverse_iterator.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+//       reverse_iterator rbegin() noexcept;
+// const_reverse_iterator rbegin() const noexcept;
+//       reverse_iterator rend()   noexcept;
+// const_reverse_iterator rend()   const noexcept;
+//
+// const_reverse_iterator crbegin() const noexcept;
+// const_reverse_iterator crend()   const noexcept;
+
+#include <cassert>
+#include <cstddef>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include <iterator>
+
+#include "test_macros.h"
+#include <iostream>
+
+void test() {
+  {
+    using M        = std::flat_multiset<int, std::less<int>, std::deque<int>>;
+    M m            = {1, 1, 2, 2, 3, 4};
+    int expected[] = {1, 1, 2, 2, 3, 4};
+    const M& cm    = m;
+    ASSERT_SAME_TYPE(decltype(m.rbegin()), M::reverse_iterator);
+    ASSERT_SAME_TYPE(decltype(m.crbegin()), M::const_reverse_iterator);
+    ASSERT_SAME_TYPE(decltype(cm.rbegin()), M::const_reverse_iterator);
+    ASSERT_SAME_TYPE(decltype(m.rend()), M::reverse_iterator);
+    ASSERT_SAME_TYPE(decltype(m.crend()), M::const_reverse_iterator);
+    ASSERT_SAME_TYPE(decltype(cm.rend()), M::const_reverse_iterator);
+    static_assert(noexcept(m.rbegin()));
+    static_assert(noexcept(cm.rbegin()));
+    static_assert(noexcept(m.crbegin()));
+    static_assert(noexcept(m.rend()));
+    static_assert(noexcept(cm.rend()));
+    static_assert(noexcept(m.crend()));
+    assert(m.size() == 6);
+    assert(std::distance(m.rbegin(), m.rend()) == 6);
+    assert(std::distance(cm.rbegin(), cm.rend()) == 6);
+    assert(std::distance(m.crbegin(), m.crend()) == 6);
+    assert(std::distance(cm.crbegin(), cm.crend()) == 6);
+    M::reverse_iterator i; // default-construct
+    ASSERT_SAME_TYPE(decltype(*i), const int&);
+    i                           = m.rbegin(); // move-assignment
+    M::const_reverse_iterator k = i;          // converting constructor
+    assert(i == k);                           // comparison
+    for (int j = 5; j >= 0; --j, ++i) {       // pre-increment
+      assert(*i == expected[j]);
+    }
+    assert(i == m.rend());
+    for (int j = 0; j <= 5; ++j) {
+      --i; // pre-decrement
+      assert(*i == expected[j]);
+    }
+    assert(i == m.rbegin());
+  }
+  {
+    // N3644 testing
+    using C = std::flat_multiset<int>;
+    C::reverse_iterator ii1{}, ii2{};
+    C::reverse_iterator ii4 = ii1;
+    C::const_reverse_iterator cii{};
+    assert(ii1 == ii2);
+    assert(ii1 == ii4);
+    assert(!(ii1 != ii2));
+
+    assert((ii1 == cii));
+    assert((cii == ii1));
+    assert(!(ii1 != cii));
+    assert(!(cii != ii1));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/clear.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/clear.pass.cpp
new file mode 100644
index 0000000000000..4d01ece7ed6a6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/clear.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// class flat_multiset
+
+// void clear() noexcept;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// test noexcept
+
+template <class T>
+concept NoExceptClear = requires(T t) {
+  { t.clear() } noexcept;
+};
+
+static_assert(NoExceptClear<std::flat_multiset<int>>);
+#ifndef TEST_HAS_NO_EXCEPTIONS
+static_assert(NoExceptClear<std::flat_multiset<int, std::less<int>, ThrowOnMoveContainer<int>>>);
+#endif
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  {
+    M m = {1, 1, 3, 5, 2, 3, 4, 5};
+    assert(m.size() == 8);
+    ASSERT_NOEXCEPT(m.clear());
+    ASSERT_SAME_TYPE(decltype(m.clear()), void);
+    m.clear();
+    assert(m.size() == 0);
+  }
+  {
+    // was empty
+    M m;
+    assert(m.size() == 0);
+    m.clear();
+    assert(m.size() == 0);
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000000000..3ef13964c905e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template <class... Args>
+//  iterator emplace(Args&&... args);
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+#include <tuple>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using R   = typename M::iterator;
+  {
+    // was empty
+    M m;
+    std::same_as<R> decltype(auto) r = m.emplace(typename M::value_type(2));
+    assert(r == m.begin());
+    assert(m.size() == 1);
+    assert(*r == 2);
+  }
+  {
+    // key does not exist and inserted at the begin
+    M m                              = {3, 3, 3, 7};
+    std::same_as<R> decltype(auto) r = m.emplace(typename M::value_type(2));
+    assert(r == m.begin());
+    assert(m.size() == 5);
+    assert(*r == 2);
+  }
+  {
+    // key does not exist and inserted in the middle
+    M m                              = {1, 1, 3, 4};
+    std::same_as<R> decltype(auto) r = m.emplace(typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 5);
+    assert(*r == 2);
+  }
+  {
+    // key does not exist and inserted at the end
+    M m                              = {1, 1};
+    std::same_as<R> decltype(auto) r = m.emplace(typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 3);
+    assert(*r == 2);
+  }
+  {
+    // key already exists and original at the begin
+    M m                              = {2, 2, 5, 6};
+    std::same_as<R> decltype(auto) r = m.emplace(typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 5);
+    assert(*r == 2);
+  }
+  {
+    // key already exists and original in the middle
+    M m                              = {0, 2, 2, 4};
+    std::same_as<R> decltype(auto) r = m.emplace(typename M::value_type(2));
+    assert(r == m.begin() + 3);
+    assert(m.size() == 5);
+    assert(*r == 2);
+  }
+  {
+    // key already exists and original at the end
+    M m                              = {0, 1, 2};
+    std::same_as<R> decltype(auto) r = m.emplace(typename M::value_type(2));
+    assert(r == m.begin() + 3);
+    assert(m.size() == 4);
+    assert(*r == 2);
+  }
+}
+
+template <class KeyContainer>
+void test_emplaceable() {
+  using M = std::flat_multiset<Emplaceable, std::less<Emplaceable>, KeyContainer>;
+  using R = typename M::iterator;
+
+  M m;
+  ASSERT_SAME_TYPE(decltype(m.emplace()), R);
+  R r = m.emplace(2, 0.0);
+  assert(r == m.begin());
+  assert(m.size() == 1);
+  assert(*r == Emplaceable(2, 0.0));
+  r = m.emplace(1, 3.5);
+  assert(r == m.begin());
+  assert(m.size() == 2);
+  assert(*r == Emplaceable(1, 3.5));
+  r = m.emplace(1, 3.5);
+  assert(r == m.begin() + 1);
+  assert(m.size() == 3);
+  assert(*r == Emplaceable(1, 3.5));
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+
+  test_emplaceable<std::vector<Emplaceable>>();
+  test_emplaceable<std::deque<Emplaceable>>();
+  test_emplaceable<MinSequenceContainer<Emplaceable>>();
+  test_emplaceable<std::vector<Emplaceable, min_allocator<Emplaceable>>>();
+}
+
+void test_exception() {
+  auto emplace_func = [](auto& m, auto key_arg) { m.emplace(key_arg); };
+  test_emplace_exception_guarantee(emplace_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace_hint.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000000000..41a2e9c4ce115
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,241 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+#include "../helpers.h"
+
+struct CompareTensDigit {
+  bool operator()(auto lhs, auto rhs) const { return (lhs / 10) < (rhs / 10); }
+};
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using R   = M::iterator;
+
+  {
+    // was empty
+    M m;
+    std::same_as<R> decltype(auto) r = m.emplace_hint(m.end(), typename M::value_type(2));
+    assert(r == m.begin());
+    assert(m.size() == 1);
+    assert(*r == 2);
+  }
+  {
+    // hints correct and no duplicates
+    M m                              = {0, 1, 3};
+    auto hint                        = m.begin() + 2;
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 4);
+    assert(*r == 2);
+  }
+  {
+    // hints correct at the begin
+    M m                              = {3, 4};
+    auto hint                        = m.begin();
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin());
+    assert(m.size() == 3);
+    assert(*r == 2);
+  }
+  {
+    // hints correct in the middle
+    M m                              = {0, 1, 3, 4};
+    auto hint                        = m.begin() + 2;
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 5);
+    assert(*r == 2);
+  }
+  {
+    // hints correct at the end
+    M m                              = {0, 1};
+    auto hint                        = m.end();
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 3);
+    assert(*r == 2);
+  }
+  {
+    // hints correct but key already exists
+    M m                              = {0, 1, 2, 3, 4};
+    auto hint                        = m.begin() + 2;
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 6);
+    assert(*r == 2);
+  }
+  {
+    // hint correct and at the first duplicate
+    using M2 = std::flat_multiset<Key, CompareTensDigit, KeyContainer>;
+    using R2 = M2::iterator;
+    M2 m{0, 10, 20, 25, 30};
+    auto hint                         = m.begin() + 2;
+    std::same_as<R2> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(21));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 6);
+    assert(*r == 21);
+  }
+  {
+    // hint correct and in-between duplicates
+    using M2 = std::flat_multiset<Key, CompareTensDigit, KeyContainer>;
+    using R2 = M2::iterator;
+    M2 m{0, 10, 20, 21, 22, 30};
+    auto hint                         = m.begin() + 4;
+    std::same_as<R2> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(23));
+    assert(r == m.begin() + 4);
+    assert(m.size() == 7);
+    assert(*r == 23);
+    assert(*std::next(r) == 22);
+  }
+  {
+    // hint correct and after duplicates
+    using M2 = std::flat_multiset<Key, CompareTensDigit, KeyContainer>;
+    using R2 = M2::iterator;
+    M2 m{0, 10, 20, 21, 22, 30};
+    auto hint                         = m.begin() + 5;
+    std::same_as<R2> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(23));
+    assert(r == m.begin() + 5);
+    assert(m.size() == 7);
+    assert(*r == 23);
+    assert(*std::next(r) == 30);
+  }
+  {
+    // hints incorrect and no duplicates
+    M m                              = {0, 1, 3};
+    auto hint                        = m.begin() + 1;
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 4);
+    assert(*r == 2);
+  }
+  {
+    // hints incorrectly at the begin
+    M m                              = {1, 4};
+    auto hint                        = m.begin();
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 1);
+    assert(m.size() == 3);
+    assert(*r == 2);
+  }
+  {
+    // hints incorrectly in the middle
+    M m                              = {0, 1, 3, 4};
+    auto hint                        = m.begin() + 1;
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 5);
+    assert(*r == 2);
+  }
+  {
+    // hints incorrectly at the end
+    M m                              = {0, 3};
+    auto hint                        = m.end();
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 1);
+    assert(m.size() == 3);
+    assert(*r == 2);
+  }
+  {
+    // hints incorrect and key already exists
+    M m                              = {0, 1, 2, 3, 4};
+    auto hint                        = m.begin();
+    std::same_as<R> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(2));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 6);
+    assert(*r == 2);
+  }
+  {
+    // hint incorrect and before the first duplicate
+    using M2 = std::flat_multiset<Key, CompareTensDigit, KeyContainer>;
+    using R2 = M2::iterator;
+    M2 m{0, 10, 20, 21, 22, 30};
+    auto hint                         = m.begin();
+    std::same_as<R2> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(23));
+    assert(r == m.begin() + 2);
+    assert(m.size() == 7);
+    assert(*r == 23);
+    assert(*std::next(r) == 20);
+  }
+  {
+    // hint incorrect and after the last duplicate
+    using M2 = std::flat_multiset<Key, CompareTensDigit, KeyContainer>;
+    using R2 = M2::iterator;
+    M2 m{0, 10, 20, 21, 22, 30, 40};
+    auto hint                         = m.begin() + 6;
+    std::same_as<R2> decltype(auto) r = m.emplace_hint(hint, typename M::value_type(23));
+    assert(r == m.begin() + 5);
+    assert(m.size() == 8);
+    assert(*r == 23);
+    assert(*std::next(r) == 30);
+  }
+}
+
+template <class KeyContainer>
+void test_emplaceable() {
+  using M = std::flat_multiset<Emplaceable, std::less<Emplaceable>, KeyContainer>;
+  using R = M::iterator;
+
+  M m;
+  ASSERT_SAME_TYPE(decltype(m.emplace_hint(m.cbegin())), R);
+  R r = m.emplace_hint(m.end(), 2, 0.0);
+  assert(r == m.begin());
+  assert(m.size() == 1);
+  assert(*m.begin() == Emplaceable(2, 0.0));
+  r = m.emplace_hint(m.end(), 1, 3.5);
+  assert(r == m.begin());
+  assert(m.size() == 2);
+  assert(*m.begin() == Emplaceable(1, 3.5));
+  r = m.emplace_hint(m.end(), 1, 3.5);
+  assert(r == m.begin() + 1);
+  assert(m.size() == 3);
+  assert(*r == Emplaceable(1, 3.5));
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+
+  test_emplaceable<std::vector<Emplaceable>>();
+  test_emplaceable<std::vector<Emplaceable>>();
+  test_emplaceable<MinSequenceContainer<Emplaceable>>();
+  test_emplaceable<std::vector<Emplaceable, min_allocator<Emplaceable>>>();
+}
+
+void test_exception() {
+  auto emplace_func = [](auto& m, auto key_arg) { m.emplace_hint(m.begin(), key_arg); };
+  test_emplace_exception_guarantee(emplace_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000000000..8418efa67bb23
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// iterator erase(iterator position);
+// iterator erase(const_iterator position);
+
+#include <compare>
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using I   = M::iterator;
+
+  int ar[] = {
+      1,
+      3,
+      3,
+      3,
+      5,
+      5,
+      7,
+      8,
+  };
+  M m(ar, ar + sizeof(ar) / sizeof(ar[0]));
+
+  auto make = [](std::initializer_list<int> il) {
+    M m2;
+    for (int i : il) {
+      m2.emplace(i);
+    }
+    return m2;
+  };
+  assert(m.size() == 8);
+  assert(m == make({1, 3, 3, 3, 5, 5, 7, 8}));
+  std::same_as<I> decltype(auto) i1 = m.erase(std::next(m.cbegin(), 3));
+  assert(m.size() == 7);
+  assert(i1 == std::next(m.begin(), 3));
+  assert(m == make({1, 3, 3, 5, 5, 7, 8}));
+
+  std::same_as<I> decltype(auto) i2 = m.erase(std::next(m.begin(), 0));
+  assert(m.size() == 6);
+  assert(i2 == m.begin());
+  assert(m == make({3, 3, 5, 5, 7, 8}));
+
+  std::same_as<I> decltype(auto) i3 = m.erase(std::next(m.cbegin(), 5));
+  assert(m.size() == 5);
+  assert(i3 == m.end());
+  assert(m == make({3, 3, 5, 5, 7}));
+
+  std::same_as<I> decltype(auto) i4 = m.erase(std::next(m.begin(), 1));
+  assert(m.size() == 4);
+  assert(i4 == std::next(m.begin()));
+  assert(m == make({3, 5, 5, 7}));
+
+  std::same_as<I> decltype(auto) i5 = m.erase(std::next(m.cbegin(), 2));
+  assert(m.size() == 3);
+  assert(i5 == std::next(m.begin(), 2));
+  assert(m == make({3, 5, 7}));
+
+  std::same_as<I> decltype(auto) i6 = m.erase(std::next(m.begin(), 2));
+  assert(m.size() == 2);
+  assert(i6 == std::next(m.begin(), 2));
+  assert(m == make({3, 5}));
+
+  std::same_as<I> decltype(auto) i7 = m.erase(std::next(m.cbegin(), 0));
+  assert(m.size() == 1);
+  assert(i7 == std::next(m.begin(), 0));
+  assert(m == make({5}));
+
+  std::same_as<I> decltype(auto) i8 = m.erase(m.begin());
+  assert(m.size() == 0);
+  assert(i8 == m.begin());
+  assert(i8 == m.end());
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto erase_function = [](auto& m, auto) { m.erase(m.begin() + 2); };
+  test_erase_exception_guarantee(erase_function);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..2d54fef17b6c0
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <compare>
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using I   = M::iterator;
+
+  auto make = [](std::initializer_list<int> il) {
+    M m;
+    for (int i : il) {
+      m.emplace(i);
+    }
+    return m;
+  };
+
+  int ar[] = {
+      1,
+      1,
+      3,
+      3,
+      5,
+      6,
+      6,
+      8,
+  };
+  M m(ar, ar + sizeof(ar) / sizeof(ar[0]));
+  assert(m.size() == 8);
+  std::same_as<I> decltype(auto) i1 = m.erase(m.cbegin(), m.cbegin());
+  assert(m.size() == 8);
+  assert(i1 == m.begin());
+  assert(m == make({1, 1, 3, 3, 5, 6, 6, 8}));
+
+  std::same_as<I> decltype(auto) i2 = m.erase(m.cbegin(), std::next(m.cbegin(), 2));
+  assert(m.size() == 6);
+  assert(i2 == m.begin());
+  assert(m == make({3, 3, 5, 6, 6, 8}));
+
+  std::same_as<I> decltype(auto) i3 = m.erase(std::next(m.cbegin(), 2), std::next(m.cbegin(), 6));
+  assert(m.size() == 2);
+  assert(i3 == std::next(m.begin(), 2));
+  assert(m == make({3, 3}));
+
+  std::same_as<I> decltype(auto) i4 = m.erase(m.cbegin(), m.cend());
+  assert(m.size() == 0);
+  assert(i4 == m.begin());
+  assert(i4 == m.end());
+
+  // was empty
+  std::same_as<I> decltype(auto) i5 = m.erase(m.cbegin(), m.cend());
+  assert(m.size() == 0);
+  assert(i5 == m.begin());
+  assert(i5 == m.end());
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto erase_function = [](auto& m, auto) { m.erase(m.begin(), m.begin() + 2); };
+  test_erase_exception_guarantee(erase_function);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000000000..8175afa5b626e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// size_type erase(const key_type& k);
+
+#include <compare>
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer, class Compare = std::less<>>
+void test_one() {
+  using M = std::flat_multiset<int, Compare, KeyContainer>;
+
+  auto make = [](std::initializer_list<int> il) {
+    M m;
+    for (int i : il) {
+      m.emplace(i);
+    }
+    return m;
+  };
+  M m = make({1, 1, 3, 5, 5, 5, 7, 8});
+  ASSERT_SAME_TYPE(decltype(m.erase(9)), typename M::size_type);
+  auto n = m.erase(9);
+  assert(n == 0);
+  assert(m == make({1, 1, 3, 5, 5, 5, 7, 8}));
+  n = m.erase(4);
+  assert(n == 0);
+  assert(m == make({1, 1, 3, 5, 5, 5, 7, 8}));
+  n = m.erase(1);
+  assert(n == 2);
+  assert(m == make({3, 5, 5, 5, 7, 8}));
+  n = m.erase(8);
+  assert(n == 1);
+  assert(m == make({3, 5, 5, 5, 7}));
+  n = m.erase(3);
+  assert(n == 1);
+  assert(m == make({5, 5, 5, 7}));
+  n = m.erase(4);
+  assert(n == 0);
+  assert(m == make({5, 5, 5, 7}));
+  n = m.erase(6);
+  assert(n == 0);
+  assert(m == make({5, 5, 5, 7}));
+  n = m.erase(7);
+  assert(n == 1);
+  assert(m == make({5, 5, 5}));
+  n = m.erase(2);
+  assert(n == 0);
+  assert(m == make({5, 5, 5}));
+  n = m.erase(5);
+  assert(n == 3);
+  assert(m.empty());
+  // was empty
+  n = m.erase(5);
+  assert(n == 0);
+  assert(m.empty());
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::vector<int>, std::greater<>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto erase_function = [](auto& m, auto key_arg) {
+    using Set = std::decay_t<decltype(m)>;
+    using Key = typename Set::key_type;
+    const Key key{key_arg};
+    m.erase(key);
+  };
+  test_erase_exception_guarantee(erase_function);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key_transparent.pass.cpp
new file mode 100644
index 0000000000000..a8765495d91d4
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/erase_key_transparent.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// size_type erase(K&& k);
+
+#include <compare>
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// Constraints: The qualified-id Compare::is_transparent is valid and denotes a type.
+template <class M>
+concept CanErase        = requires(M m, Transparent<int> k) { m.erase(k); };
+using TransparentSet    = std::flat_multiset<int, TransparentComparator>;
+using NonTransparentSet = std::flat_multiset<int, NonTransparentComparator>;
+static_assert(CanErase<TransparentSet>);
+static_assert(!CanErase<const TransparentSet>);
+static_assert(!CanErase<NonTransparentSet>);
+static_assert(!CanErase<const NonTransparentSet>);
+
+template <class Key, class It>
+struct HeterogeneousKey {
+  explicit HeterogeneousKey(Key key, It it) : key_(key), it_(it) {}
+  operator It() && { return it_; }
+  auto operator<=>(Key key) const { return key_ <=> key; }
+  friend bool operator<(const HeterogeneousKey&, const HeterogeneousKey&) {
+    assert(false);
+    return false;
+  }
+  Key key_;
+  It it_;
+};
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+
+  M m = {1, 2, 3, 3, 4};
+  ASSERT_SAME_TYPE(decltype(m.erase(9)), typename M::size_type);
+  auto n = m.erase(3); // erase(K&&) [with K=int]
+  assert(n == 2);
+  assert((m == M{1, 2, 4}));
+  typename M::key_type lvalue = 2;
+  n                           = m.erase(lvalue); // erase(K&&) [with K=int&]
+  assert(n == 1);
+  assert((m == M{1, 4}));
+  const typename M::key_type const_lvalue = 1;
+  n                                       = m.erase(const_lvalue); // erase(const key_type&)
+  assert(n == 1);
+  assert((m == M{4}));
+}
+
+template <class KeyContainer>
+void test_transparent_comparator() {
+  using M = std::flat_multiset<std::string, TransparentComparator, KeyContainer>;
+  {
+    M m = {"alpha", "beta", "beta", "epsilon", "epsilon", "epsilon", "eta", "eta", "gamma"};
+    ASSERT_SAME_TYPE(decltype(m.erase(Transparent<std::string>{"abc"})), typename M::size_type);
+
+    auto n = m.erase(Transparent<std::string>{"epsilon"});
+    assert(n == 3);
+
+    M expected = {"alpha", "beta", "beta", "eta", "eta", "gamma"};
+    assert(m == expected);
+
+    auto n2 = m.erase(Transparent<std::string>{"aaa"});
+    assert(n2 == 0);
+    assert(m == expected);
+  }
+  {
+    // was empty
+    M m;
+    auto n = m.erase(Transparent<std::string>{"epsilon"});
+    assert(n == 0);
+    assert(m.empty());
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+
+  test_transparent_comparator<std::vector<std::string>>();
+  test_transparent_comparator<std::deque<std::string>>();
+  test_transparent_comparator<MinSequenceContainer<std::string>>();
+  test_transparent_comparator<std::vector<std::string, min_allocator<std::string>>>();
+
+  {
+    // P2077's HeterogeneousKey example
+    using M                           = std::flat_multiset<int, std::less<>>;
+    M m                               = {1, 2, 3, 4, 5, 6, 7, 8};
+    auto h1                           = HeterogeneousKey<int, M::iterator>(8, m.begin());
+    std::same_as<M::size_type> auto n = m.erase(h1); // lvalue is not convertible to It; erase(K&&) is the best match
+    assert(n == 1);
+    assert((m == M{1, 2, 3, 4, 5, 6, 7}));
+    std::same_as<M::iterator> auto it = m.erase(std::move(h1)); // rvalue is convertible to It; erase(K&&) drops out
+    assert(it == m.begin());
+    assert((m == M{2, 3, 4, 5, 6, 7}));
+  }
+  {
+    using M                           = std::flat_multiset<int, std::less<>>;
+    M m                               = {1, 2, 3, 4, 5, 6, 7, 8};
+    auto h1                           = HeterogeneousKey<int, M::const_iterator>(8, m.begin());
+    std::same_as<M::size_type> auto n = m.erase(h1); // lvalue is not convertible to It; erase(K&&) is the best match
+    assert(n == 1);
+    assert((m == M{1, 2, 3, 4, 5, 6, 7}));
+    std::same_as<M::iterator> auto it = m.erase(std::move(h1)); // rvalue is convertible to It; erase(K&&) drops out
+    assert(it == m.begin());
+    assert((m == M{2, 3, 4, 5, 6, 7}));
+  }
+  {
+    bool transparent_used = false;
+    TransparentComparator c(transparent_used);
+    std::flat_multiset<int, TransparentComparator> m(std::sorted_equivalent, {1, 2, 3}, c);
+    assert(!transparent_used);
+    auto n = m.erase(Transparent<int>{3});
+    assert(n == 1);
+    assert(transparent_used);
+  }
+  {
+    // std::string and C string literal
+    using M = std::flat_multiset<std::string, std::less<>>;
+    M m     = {"alpha", "beta", "beta", "epsilon", "eta", "gamma"};
+    auto n  = m.erase("beta");
+    assert(n == 2);
+    assert((m == M{"alpha", "epsilon", "eta", "gamma"}));
+  }
+}
+
+void test_exception() {
+  auto erase_transparent = [](auto& m, auto key_arg) {
+    using Set = std::decay_t<decltype(m)>;
+    using Key = typename Set::key_type;
+    m.erase(Transparent<Key>{key_arg});
+  };
+  test_erase_exception_guarantee(erase_transparent);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/extract.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/extract.pass.cpp
new file mode 100644
index 0000000000000..8a66431396916
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/extract.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// container_type extract() &&;
+
+#include <algorithm>
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class T>
+concept CanExtract = requires(T&& t) { std::forward<T>(t).extract(); };
+
+static_assert(CanExtract<std::flat_multiset<int>&&>);
+static_assert(!CanExtract<std::flat_multiset<int>&>);
+static_assert(!CanExtract<std::flat_multiset<int> const&>);
+static_assert(!CanExtract<std::flat_multiset<int> const&&>);
+
+template <class KeyContainer>
+void test_one() {
+  using M = std::flat_multiset<int, std::less<int>, KeyContainer>;
+  {
+    M m = M({1, 1, 3});
+
+    std::same_as<KeyContainer> auto keys = std::move(m).extract();
+
+    auto expected_keys = {1, 1, 3};
+    assert(std::ranges::equal(keys, expected_keys));
+    check_invariant(m);
+    LIBCPP_ASSERT(m.empty());
+  }
+  {
+    // was empty
+    M m;
+    assert(m.empty());
+    auto keys = std::move(m).extract();
+    assert(keys.empty());
+    LIBCPP_ASSERT(m.empty());
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+
+  {
+    // extracted object maintains invariant if the underlying container does not clear after move
+    using M                                   = std::flat_multiset<int, std::less<>, CopyOnlyVector<int>>;
+    M m                                       = M({1, 1, 3});
+    std::same_as<M::container_type> auto keys = std::move(m).extract();
+    assert(keys.size() == 3);
+    check_invariant(m);
+    LIBCPP_ASSERT(m.empty());
+  }
+}
+
+void test_exception() {
+  {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+    using KeyContainer = ThrowOnMoveContainer<int>;
+    using M            = std::flat_multiset<int, std::ranges::less, KeyContainer>;
+
+    M m;
+    m.emplace(1);
+    m.emplace(2);
+    try {
+      auto c = std::move(m).extract();
+      assert(false);
+    } catch (int) {
+      check_invariant(m);
+      // In libc++, we try to erase the key after value emplacement failure.
+      // and after erasure failure, we clear the flat_multiset
+      LIBCPP_ASSERT(m.size() == 0);
+    }
+#endif
+  }
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_cv.pass.cpp
new file mode 100644
index 0000000000000..eeb1bdd26ca16
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// iterator insert(const value_type& v);
+
+#include <flat_set>
+#include <deque>
+#include <cassert>
+#include <functional>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "../helpers.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using R   = typename M::iterator;
+  using VT  = typename M::value_type;
+  M m;
+
+  const VT v1(2);
+  std::same_as<R> decltype(auto) r = m.insert(v1);
+  assert(r == m.begin());
+  assert(m.size() == 1);
+  assert(*r == 2);
+
+  const VT v2(1);
+  r = m.insert(v2);
+  assert(r == m.begin());
+  assert(m.size() == 2);
+  assert(*r == 1);
+
+  const VT v3(3);
+  r = m.insert(v3);
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 3);
+  assert(*r == 3);
+
+  const VT v4(3);
+  r = m.insert(v4);
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 4);
+  assert(*r == 3);
+
+  const VT v5(1);
+  r = m.insert(v5);
+  assert(r == m.begin() + 1);
+  assert(m.size() == 5);
+  assert(*r == 1);
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, auto key_arg) {
+    using value_type = typename std::decay_t<decltype(m)>::value_type;
+    const value_type p(key_arg);
+    m.insert(p);
+  };
+  test_emplace_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..9c56d3bfb750b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// void insert(initializer_list<value_type> il);
+
+#include <flat_set>
+#include <cassert>
+#include <functional>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+
+  {
+    M m = {1, 1, 1, 3, 3, 3};
+    m.insert({
+        4,
+        4,
+        4,
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+    });
+    assert(m.size() == 15);
+
+    KeyContainer expected{1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+    assert(std::ranges::equal(m, expected));
+  }
+  {
+    // was empty
+    M m;
+    m.insert({
+        4,
+        4,
+        4,
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+    });
+    assert(m.size() == 9);
+    KeyContainer expected{1, 1, 1, 2, 2, 2, 4, 4, 4};
+    assert(std::ranges::equal(m, expected));
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, const auto& newValues) {
+    using FlatSet                        = std::decay_t<decltype(m)>;
+    using value_type                     = typename FlatSet::value_type;
+    std::initializer_list<value_type> il = {newValues[0]};
+    m.insert(il);
+  };
+  test_insert_range_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000000000..61f00f5138118
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <flat_set>
+#include <cassert>
+#include <functional>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "../helpers.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using R   = typename M::iterator;
+  using VT  = typename M::value_type;
+
+  M m;
+  const VT v1(2);
+  std::same_as<R> decltype(auto) r = m.insert(m.end(), v1);
+  assert(r == m.begin());
+  assert(m.size() == 1);
+  assert(*r == 2);
+
+  const VT v2(1);
+  r = m.insert(m.end(), v2);
+  assert(r == m.begin());
+  assert(m.size() == 2);
+  assert(*r == 1);
+
+  const VT v3(3);
+  r = m.insert(m.end(), v3);
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 3);
+  assert(*r == 3);
+
+  const VT v4(3);
+  r = m.insert(m.end(), v4);
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 4);
+  assert(*r == 3);
+
+  const VT v5(1);
+  r = m.insert(m.begin() + 2, v5);
+  assert(r == m.begin() + 1);
+  assert(m.size() == 5);
+  assert(*r == 1);
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, auto key_arg) {
+    using FlatSet    = std::decay_t<decltype(m)>;
+    using value_type = typename FlatSet::value_type;
+    const value_type p(key_arg);
+    m.insert(m.begin(), p);
+  };
+  test_emplace_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..3505e097cca69
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <flat_set>
+#include <cassert>
+#include <functional>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+// test constraint InputIterator
+template <class M, class... Args>
+concept CanInsert = requires(M m, Args&&... args) { m.insert(std::forward<Args>(args)...); };
+
+using Set = std::flat_multiset<int>;
+
+static_assert(CanInsert<Set, int*, int*>);
+static_assert(CanInsert<Set, cpp17_input_iterator<int*>, cpp17_input_iterator<int*>>);
+static_assert(!CanInsert<Set, int, int>);
+static_assert(!CanInsert<Set, cpp20_input_iterator<int*>, cpp20_input_iterator<int*>>);
+
+template <class KeyContainer>
+void test_one() {
+  using M = std::flat_multiset<int, std::less<int>, KeyContainer>;
+
+  int ar1[] = {
+      2,
+      2,
+      2,
+      1,
+      1,
+      1,
+      3,
+      3,
+      3,
+  };
+  int ar2[] = {
+      4,
+      4,
+      4,
+      1,
+      1,
+      1,
+      0,
+      0,
+      0,
+  };
+
+  M m;
+  m.insert(cpp17_input_iterator<int*>(ar1), cpp17_input_iterator<int*>(ar1 + sizeof(ar1) / sizeof(ar1[0])));
+  assert(m.size() == 9);
+  M expected{1, 1, 1, 2, 2, 2, 3, 3, 3};
+  assert(m == expected);
+
+  m.insert(cpp17_input_iterator<int*>(ar2), cpp17_input_iterator<int*>(ar2 + sizeof(ar2) / sizeof(ar2[0])));
+  assert(m.size() == 18);
+  M expected2{0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+  assert(m == expected2);
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, const auto& newValues) { m.insert(newValues.begin(), newValues.end()); };
+  test_insert_range_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000000000..9976c04c9973a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+//     iterator insert(const_iterator position, value_type&&);
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+#include "../helpers.h"
+#include "test_macros.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  using V   = Key;
+  using R   = typename M::iterator;
+  M m;
+  std::same_as<R> decltype(auto) r = m.insert(m.end(), V(2));
+  assert(r == m.begin());
+  assert(m.size() == 1);
+  assert(*r == V(2));
+
+  r = m.insert(m.end(), V(1));
+  assert(r == m.begin());
+  assert(m.size() == 2);
+  assert(*r == V(1));
+
+  r = m.insert(m.end(), V(3));
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 3);
+  assert(*r == V(3));
+
+  r = m.insert(m.end(), V(3));
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 4);
+  assert(*r == V(3));
+
+  r = m.insert(m.begin(), V(2));
+  assert(r == m.begin() + 1);
+  assert(m.size() == 5);
+  assert(*r == V(2));
+
+  r = m.insert(m.begin() + 2, V(1));
+  assert(r == m.begin() + 1);
+  assert(m.size() == 6);
+  assert(*r == V(1));
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::vector<MoveOnly>>();
+  test_one<std::deque<int>>();
+  test_one<std::deque<MoveOnly>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<MinSequenceContainer<MoveOnly>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+  test_one<std::vector<MoveOnly, min_allocator<MoveOnly>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, auto key_arg) {
+    using FlatSet    = std::decay_t<decltype(m)>;
+    using value_type = typename FlatSet::value_type;
+    value_type p(key_arg);
+    m.insert(m.begin(), std::move(p));
+  };
+  test_emplace_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_range.pass.cpp
new file mode 100644
index 0000000000000..566be3921bf77
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_range.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<container-compatible-range<value_type> R>
+//   void insert_range(R&& rg);
+
+#include <algorithm>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <ranges>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "MoveOnly.h"
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+// test constraint container-compatible-range
+template <class M, class R>
+concept CanInsertRange = requires(M m, R&& r) { m.insert_range(std::forward<R>(r)); };
+
+using Set = std::flat_multiset<int, double>;
+
+static_assert(CanInsertRange<Set, std::ranges::subrange<int*>>);
+static_assert(CanInsertRange<Set, std::ranges::subrange<short*>>);
+static_assert(!CanInsertRange<Set, std::ranges::subrange<std::pair<int, int>*>>);
+static_assert(!CanInsertRange<Set, std::ranges::subrange<std::pair<short, short>*>>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+
+  {
+    using M                 = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+    using It                = forward_iterator<const int*>;
+    M m                     = {10, 10, 8, 5, 2, 1, 1};
+    int ar[]                = {3, 1, 4, 1, 5, 9};
+    std::ranges::subrange r = {It(ar), It(ar + 6)};
+    static_assert(std::ranges::common_range<decltype(r)>);
+    m.insert_range(r);
+    assert((m == M{1, 1, 1, 1, 2, 3, 4, 5, 5, 8, 9, 10, 10}));
+  }
+  {
+    using M                 = std::flat_multiset<Key, std::greater<>, KeyContainer>;
+    using It                = cpp20_input_iterator<const int*>;
+    M m                     = {10, 10, 8, 5, 2, 1, 1};
+    int ar[]                = {3, 1, 4, 1, 5, 9};
+    std::ranges::subrange r = {It(ar), sentinel_wrapper<It>(It(ar + 6))};
+    static_assert(!std::ranges::common_range<decltype(r)>);
+    m.insert_range(r);
+    assert((m == M{1, 1, 1, 1, 2, 3, 4, 5, 5, 8, 9, 10, 10}));
+  }
+  {
+    // was empty
+    using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+    M m;
+    int ar[] = {3, 1, 4, 1, 5, 9};
+    m.insert_range(ar);
+    assert((m == M{1, 1, 3, 4, 5, 9}));
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+  {
+    // Items are forwarded correctly from the input range.
+    MoveOnly a[] = {3, 1, 4, 1, 5};
+    std::flat_multiset<MoveOnly> m;
+    m.insert_range(a | std::views::as_rvalue);
+    MoveOnly expected[] = {1, 1, 3, 4, 5};
+    assert(std::ranges::equal(m, expected));
+  }
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, const auto& newValues) { m.insert_range(newValues); };
+  test_insert_range_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_rv.pass.cpp
new file mode 100644
index 0000000000000..9328c42fb0cda
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// class flat_multiset
+
+// iterator insert(value_type&& v);
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+#include "test_macros.h"
+#include "../helpers.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, TransparentComparator, KeyContainer>;
+  using R   = typename M::iterator;
+  using V   = typename M::value_type;
+
+  M m;
+  std::same_as<R> decltype(auto) r = m.insert(V(2));
+  assert(r == m.begin());
+  assert(m.size() == 1);
+  assert(*r == V(2));
+
+  r = m.insert(V(1));
+  assert(r == m.begin());
+  assert(m.size() == 2);
+  assert(*r == V(1));
+
+  r = m.insert(V(3));
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 3);
+  assert(*r == V(3));
+
+  r = m.insert(V(3));
+  assert(r == std::ranges::prev(m.end()));
+  assert(m.size() == 4);
+  assert(*r == V(3));
+
+  r = m.insert(V(2));
+  assert(r == m.begin() + 2);
+  assert(m.size() == 5);
+  assert(*r == V(2));
+
+  r = m.insert(V(1));
+  assert(r == m.begin() + 1);
+  assert(m.size() == 6);
+  assert(*r == V(1));
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::vector<MoveOnly>>();
+  test_one<std::deque<int>>();
+  test_one<std::deque<MoveOnly>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<MinSequenceContainer<MoveOnly>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+  test_one<std::vector<MoveOnly, min_allocator<MoveOnly>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, auto key_arg) {
+    using FlatSet    = std::decay_t<decltype(m)>;
+    using value_type = typename FlatSet::value_type;
+    value_type p(key_arg);
+    m.insert(std::move(p));
+  };
+  test_emplace_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_initializer_list.pass.cpp
new file mode 100644
index 0000000000000..11af199c3d1ee
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_initializer_list.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// void insert(sorted_equivalent_t, initializer_list<value_type> il);
+
+#include <flat_set>
+#include <cassert>
+#include <functional>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  {
+    M m = {1, 1, 1, 3, 3, 3};
+    m.insert(std::sorted_equivalent, {0, 1, 1, 2, 2, 4});
+    assert(m.size() == 12);
+    M expected = {0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4};
+    assert(m == expected);
+  }
+  {
+    // empty
+    M m;
+    m.insert(std::sorted_equivalent, {0, 1, 1, 2, 2, 4});
+    M expected = {0, 1, 1, 2, 2, 4};
+    assert(m == expected);
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, const auto& newValues) {
+    using FlatSet                        = std::decay_t<decltype(m)>;
+    using value_type                     = typename FlatSet::value_type;
+    std::initializer_list<value_type> il = {newValues[0]};
+    m.insert(std::sorted_equivalent, il);
+  };
+  test_insert_range_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..07b62d04e0ebc
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_sorted_iter_iter.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template <class InputIterator>
+//   void insert(sorted_equivalent_t, InputIterator first, InputIterator last);
+
+#include <flat_set>
+#include <cassert>
+#include <functional>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+// test constraint InputIterator
+template <class M, class... Args>
+concept CanInsert = requires(M m, Args&&... args) { m.insert(std::forward<Args>(args)...); };
+
+using Set = std::flat_multiset<int>;
+
+static_assert(CanInsert<Set, std::sorted_equivalent_t, int*, int*>);
+static_assert(CanInsert<Set, std::sorted_equivalent_t, cpp17_input_iterator<int*>, cpp17_input_iterator<int*>>);
+static_assert(!CanInsert<Set, std::sorted_equivalent_t, int, int>);
+static_assert(!CanInsert<Set, std::sorted_equivalent_t, cpp20_input_iterator<int*>, cpp20_input_iterator<int*>>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+
+  int ar1[] = {1, 2, 2, 3};
+
+  int ar2[] = {0, 2, 4, 4};
+
+  M m;
+  m.insert(std::sorted_equivalent,
+           cpp17_input_iterator<int*>(ar1),
+           cpp17_input_iterator<int*>(ar1 + sizeof(ar1) / sizeof(ar1[0])));
+  assert(m.size() == 4);
+  M expected{1, 2, 2, 3};
+  assert(m == expected);
+
+  m.insert(std::sorted_equivalent,
+           cpp17_input_iterator<int*>(ar2),
+           cpp17_input_iterator<int*>(ar2 + sizeof(ar2) / sizeof(ar2[0])));
+  assert(m.size() == 8);
+  M expected2{0, 1, 2, 2, 2, 3, 4, 4};
+  assert(m == expected2);
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+  auto insert_func = [](auto& m, const auto& newValues) {
+    m.insert(std::sorted_equivalent, newValues.begin(), newValues.end());
+  };
+  test_insert_range_exception_guarantee(insert_func);
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/replace.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/replace.pass.cpp
new file mode 100644
index 0000000000000..5fe61389d72a1
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/replace.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// void replace(container_type&& key_cont);
+
+#include <algorithm>
+#include <deque>
+#include <concepts>
+#include <flat_set>
+#include <functional>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class T, class... Args>
+concept CanReplace = requires(T t, Args&&... args) { t.replace(std::forward<Args>(args)...); };
+
+using Set = std::flat_multiset<int, int>;
+static_assert(CanReplace<Set, std::vector<int>>);
+static_assert(!CanReplace<Set, const std::vector<int>&>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  {
+    // was empty
+    M m;
+    KeyContainer new_keys = {7, 7, 8};
+    auto expected_keys    = new_keys;
+    m.replace(std::move(new_keys));
+    assert(m.size() == 3);
+    assert(std::ranges::equal(m, expected_keys));
+  }
+  {
+    M m                   = M({1, 1, 2, 2, 3});
+    KeyContainer new_keys = {7, 7, 8, 8};
+    auto expected_keys    = new_keys;
+    m.replace(std::move(new_keys));
+    assert(m.size() == 4);
+    assert(std::ranges::equal(m, expected_keys));
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+void test_exception() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  using KeyContainer = ThrowOnMoveContainer<int>;
+  using M            = std::flat_multiset<int, std::ranges::less, KeyContainer>;
+
+  M m;
+  m.emplace(1);
+  m.emplace(2);
+  try {
+    KeyContainer new_keys{3, 4};
+    m.replace(std::move(new_keys));
+    assert(false);
+  } catch (int) {
+    check_invariant(m);
+    // In libc++, we clear the set
+    LIBCPP_ASSERT(m.size() == 0);
+  }
+#endif
+}
+
+int main(int, char**) {
+  test();
+  test_exception();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_exception.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_exception.pass.cpp
new file mode 100644
index 0000000000000..705ee88994872
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_exception.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// `check_assertion.h` requires Unix headers and regex support.
+// REQUIRES: has-unix-headers
+// UNSUPPORTED: no-localization
+// UNSUPPORTED: no-exceptions
+
+// <flat_set>
+
+// void swap(flat_multiset& y) noexcept;
+// friend void swap(flat_multiset& x, flat_multiset& y) noexcept
+
+// Test that std::terminate is called if any exception is thrown during swap
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+#include <functional>
+#include <vector>
+
+#include "test_macros.h"
+#include "../helpers.h"
+#include "check_assertion.h"
+
+template <class F>
+void test_swap_exception_guarantee([[maybe_unused]] F&& swap_function) {
+  {
+    // key swap throws
+    using KeyContainer = ThrowOnMoveContainer<int>;
+    using M            = std::flat_multiset<int, TransparentComparator, KeyContainer>;
+
+    M m1, m2;
+    m1.emplace(1);
+    m1.emplace(1);
+    m2.emplace(1);
+    m2.emplace(4);
+    // swap is noexcept
+    EXPECT_STD_TERMINATE([&] { swap_function(m1, m2); });
+  }
+}
+
+int main(int, char**) {
+  {
+    auto swap_func = [](auto& m1, auto& m2) { swap(m1, m2); };
+    test_swap_exception_guarantee(swap_func);
+  }
+
+  {
+    auto swap_func = [](auto& m1, auto& m2) { m1.swap(m2); };
+    test_swap_exception_guarantee(swap_func);
+  }
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_free.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_free.pass.cpp
new file mode 100644
index 0000000000000..2e3ed02c3c00e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_free.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// friend void swap(flat_multiset& x, flat_multiset& y) noexcept
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+#include "test_macros.h"
+#include "../helpers.h"
+
+// test noexcept
+
+template <class T>
+concept NoExceptAdlSwap = requires(T t1, T t2) {
+  { swap(t1, t2) } noexcept;
+};
+
+static_assert(NoExceptAdlSwap<std::flat_multiset<int>>);
+
+#ifndef TEST_HAS_NO_EXCEPTIONS
+static_assert(NoExceptAdlSwap<std::flat_multiset<int, std::less<int>, ThrowOnMoveContainer<int>>>);
+#endif
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+
+  {
+    M m1;
+    M m2;
+    M m1_save = m1;
+    M m2_save = m2;
+    swap(m1, m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+  {
+    int ar2[] = {5, 5, 7, 8, 8, 10, 11, 12};
+    M m1;
+    M m2(ar2, ar2 + sizeof(ar2) / sizeof(ar2[0]));
+    M m1_save = m1;
+    M m2_save = m2;
+    swap(m1, m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+  {
+    int ar1[] = {1, 1, 3, 4};
+    M m1(ar1, ar1 + sizeof(ar1) / sizeof(ar1[0]));
+    M m2;
+    M m1_save = m1;
+    M m2_save = m2;
+    swap(m1, m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+  {
+    int ar1[] = {1, 1, 3, 4};
+    int ar2[] = {5, 5, 7, 8, 9, 10, 11, 12};
+    M m1(ar1, ar1 + sizeof(ar1) / sizeof(ar1[0]));
+    M m2(ar2, ar2 + sizeof(ar2) / sizeof(ar2[0]));
+    M m1_save = m1;
+    M m2_save = m2;
+    swap(m1, m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_member.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_member.pass.cpp
new file mode 100644
index 0000000000000..1d0d9152d1c1f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/swap_member.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// void swap(flat_multiset& y) noexcept;
+
+#include <flat_set>
+#include <cassert>
+#include <deque>
+#include <functional>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "MoveOnly.h"
+#include "min_allocator.h"
+#include "test_macros.h"
+#include "../helpers.h"
+
+// test noexcept
+
+template <class T>
+concept NoExceptMemberSwap = requires(T t1, T t2) {
+  { t1.swap(t2) } noexcept;
+};
+
+static_assert(NoExceptMemberSwap<std::flat_multiset<int>>);
+#ifndef TEST_HAS_NO_EXCEPTIONS
+static_assert(NoExceptMemberSwap<std::flat_multiset<int, std::less<int>, ThrowOnMoveContainer<int>>>);
+#endif
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
+  {
+    M m1;
+    M m2;
+    M m1_save = m1;
+    M m2_save = m2;
+    m1.swap(m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+  {
+    int ar2[] = {5, 5, 7, 7, 9, 10, 11, 12};
+    M m1;
+    M m2(ar2, ar2 + sizeof(ar2) / sizeof(ar2[0]));
+    M m1_save = m1;
+    M m2_save = m2;
+    m1.swap(m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+  {
+    int ar1[] = {1, 1, 3, 4};
+    M m1(ar1, ar1 + sizeof(ar1) / sizeof(ar1[0]));
+    M m2;
+    M m1_save = m1;
+    M m2_save = m2;
+    m1.swap(m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+  {
+    int ar1[] = {1, 1, 3, 4};
+    int ar2[] = {5, 5, 7, 8, 9, 10, 11, 12};
+    M m1(ar1, ar1 + sizeof(ar1) / sizeof(ar1[0]));
+    M m2(ar2, ar2 + sizeof(ar2) / sizeof(ar2[0]));
+    M m1_save = m1;
+    M m2_save = m2;
+    m1.swap(m2);
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.observers/comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.observers/comp.pass.cpp
new file mode 100644
index 0000000000000..4ca64516e242f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.observers/comp.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// key_compare key_comp() const;
+// value_compare value_comp() const;
+
+#include <cassert>
+#include <flat_set>
+#include <functional>
+#include <utility>
+#include <vector>
+
+#include "test_macros.h"
+
+void test() {
+  {
+    using M    = std::flat_multiset<int>;
+    using Comp = std::less<int>; // the default
+    M m        = {};
+    ASSERT_SAME_TYPE(M::key_compare, Comp);
+    ASSERT_SAME_TYPE(decltype(m.key_comp()), Comp);
+    ASSERT_SAME_TYPE(decltype(m.value_comp()), Comp);
+    Comp kc = m.key_comp();
+    assert(kc(1, 2));
+    assert(!kc(2, 1));
+    auto vc = m.value_comp();
+    assert(vc(1, 2));
+    assert(!vc(2, 1));
+  }
+  {
+    using Comp = std::function<bool(int, int)>;
+    using M    = std::flat_multiset<int, Comp>;
+    Comp comp  = std::greater<int>();
+    M m({}, comp);
+    ASSERT_SAME_TYPE(M::key_compare, Comp);
+    ASSERT_SAME_TYPE(decltype(m.key_comp()), Comp);
+    ASSERT_SAME_TYPE(decltype(m.value_comp()), Comp);
+    Comp kc = m.key_comp();
+    assert(!kc(1, 2));
+    assert(kc(2, 1));
+    auto vc = m.value_comp();
+    assert(!vc(1, 2));
+    assert(vc(2, 1));
+  }
+  {
+    using Comp = std::less<>;
+    using M    = std::flat_multiset<int, Comp>;
+    M m        = {};
+    ASSERT_SAME_TYPE(M::key_compare, Comp);
+    ASSERT_SAME_TYPE(decltype(m.key_comp()), Comp);
+    ASSERT_SAME_TYPE(decltype(m.value_comp()), Comp);
+    Comp kc = m.key_comp();
+    assert(kc(1, 2));
+    assert(!kc(2, 1));
+    auto vc = m.value_comp();
+    auto a  = std::make_pair(1, 2);
+    ASSERT_SAME_TYPE(decltype(vc(a, a)), bool);
+    assert(vc(1, 2));
+    assert(!vc(2, 1));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains.pass.cpp
new file mode 100644
index 0000000000000..00fda6c2edd88
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// bool contains(const key_type& x) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  {
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m     = {1, 2, 2, 2, 4, 4, 5, 8};
+    assert(!m.contains(0));
+    assert(m.contains(1));
+    assert(m.contains(2));
+    assert(!m.contains(3));
+    assert(m.contains(4));
+    assert(m.contains(5));
+    assert(!m.contains(6));
+    assert(!m.contains(7));
+    assert(std::as_const(m).contains(8));
+    assert(!std::as_const(m).contains(9));
+    m.clear();
+    assert(!m.contains(1));
+  }
+  {
+    using M = std::flat_multiset<Key, std::greater<int>, KeyContainer>;
+    M m     = {1, 2, 2, 4, 4, 5, 5, 8};
+    assert(!m.contains(0));
+    assert(m.contains(1));
+    assert(m.contains(2));
+    assert(!m.contains(3));
+    assert(m.contains(4));
+    assert(m.contains(5));
+    assert(!m.contains(6));
+    assert(!m.contains(7));
+    assert(std::as_const(m).contains(8));
+    assert(!std::as_const(m).contains(9));
+    m.clear();
+    assert(!m.contains(1));
+  }
+  {
+    // empty
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m;
+    assert(!m.contains(0));
+    assert(!m.contains(1));
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains_transparent.pass.cpp
new file mode 100644
index 0000000000000..abee2b1bb12f9
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/contains_transparent.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class K> bool contains(const K& x) const;
+
+#include <cassert>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+#include <deque>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// Constraints: The qualified-id Compare::is_transparent is valid and denotes a type.
+template <class M>
+concept CanContains     = requires(M m, Transparent<int> k) { m.contains(k); };
+using TransparentSet    = std::flat_multiset<int, TransparentComparator>;
+using NonTransparentSet = std::flat_multiset<int, NonTransparentComparator>;
+static_assert(CanContains<TransparentSet>);
+static_assert(CanContains<const TransparentSet>);
+static_assert(!CanContains<NonTransparentSet>);
+static_assert(!CanContains<const NonTransparentSet>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, TransparentComparator, KeyContainer>;
+
+  {
+    M m = {"alpha", "beta", "beta", "epsilon", "eta", "eta", "gamma"};
+    ASSERT_SAME_TYPE(decltype(m.contains(Transparent<std::string>{"abc"})), bool);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).contains(Transparent<std::string>{"b"})), bool);
+    assert(m.contains(Transparent<std::string>{"alpha"}) == true);
+    assert(m.contains(Transparent<std::string>{"beta"}) == true);
+    assert(m.contains(Transparent<std::string>{"epsilon"}) == true);
+    assert(m.contains(Transparent<std::string>{"eta"}) == true);
+    assert(m.contains(Transparent<std::string>{"gamma"}) == true);
+    assert(m.contains(Transparent<std::string>{"al"}) == false);
+    assert(m.contains(Transparent<std::string>{""}) == false);
+    assert(m.contains(Transparent<std::string>{"g"}) == false);
+  }
+  {
+    // empty
+    M m;
+    assert(m.contains(Transparent<std::string>{"gamma"}) == false);
+    assert(m.contains(Transparent<std::string>{"al"}) == false);
+  }
+}
+
+void test() {
+  test_one<std::vector<std::string>>();
+  test_one<std::deque<std::string>>();
+  test_one<MinSequenceContainer<std::string>>();
+  test_one<std::vector<std::string, min_allocator<std::string>>>();
+
+  {
+    bool transparent_used = false;
+    TransparentComparator c(transparent_used);
+    std::flat_multiset<int, TransparentComparator> m(std::sorted_equivalent, {1, 1, 2, 2, 3}, c);
+    assert(!transparent_used);
+    auto b = m.contains(Transparent<int>{3});
+    assert(b);
+    assert(transparent_used);
+  }
+  {
+    // std::string and C string literal
+    using M = std::flat_multiset<std::string, std::less<>>;
+    M m     = {"alpha", "beta", "beta", "epsilon", "eta", "gamma"};
+    assert(m.contains("beta"));
+    assert(!m.contains("charlie"));
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count.pass.cpp
new file mode 100644
index 0000000000000..1752dab0e0e3a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// size_type count(const key_type& x) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using S   = typename KeyContainer::size_type;
+
+  {
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m     = {1, 2, 2, 2, 2, 4, 4, 5, 8, 8, 8};
+    ASSERT_SAME_TYPE(decltype(m.count(0)), S);
+    assert(m.count(0) == 0);
+    assert(m.count(1) == 1);
+    assert(m.count(2) == 4);
+    assert(m.count(3) == 0);
+    assert(m.count(4) == 2);
+    assert(m.count(5) == 1);
+    assert(m.count(6) == 0);
+    assert(m.count(7) == 0);
+    assert(std::as_const(m).count(8) == 3);
+    assert(std::as_const(m).count(9) == 0);
+  }
+  {
+    using M = std::flat_multiset<Key, std::greater<int>, KeyContainer>;
+    M m     = {1, 2, 4, 4, 4, 4, 5, 5, 8};
+    ASSERT_SAME_TYPE(decltype(m.count(0)), S);
+    assert(m.count(0) == 0);
+    assert(m.count(1) == 1);
+    assert(m.count(2) == 1);
+    assert(m.count(3) == 0);
+    assert(m.count(4) == 4);
+    assert(m.count(5) == 2);
+    assert(m.count(6) == 0);
+    assert(m.count(7) == 0);
+    assert(std::as_const(m).count(8) == 1);
+    assert(std::as_const(m).count(9) == 0);
+  }
+  {
+    // empty
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m;
+    assert(m.count(0) == 0);
+    assert(m.count(1) == 0);
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count_transparent.pass.cpp
new file mode 100644
index 0000000000000..a9160aebb7517
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/count_transparent.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class K> size_type count(const K& x) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// Constraints: The qualified-id Compare::is_transparent is valid and denotes a type.
+template <class M>
+concept CanCount        = requires(M m, Transparent<int> k) { m.count(k); };
+using TransparentSet    = std::flat_multiset<int, TransparentComparator>;
+using NonTransparentSet = std::flat_multiset<int, NonTransparentComparator>;
+static_assert(CanCount<TransparentSet>);
+static_assert(CanCount<const TransparentSet>);
+static_assert(!CanCount<NonTransparentSet>);
+static_assert(!CanCount<const NonTransparentSet>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, TransparentComparator, KeyContainer>;
+  {
+    M m = {"alpha", "beta", "beta", "beta", "epsilon", "eta", "eta", "gamma"};
+    ASSERT_SAME_TYPE(decltype(m.count(Transparent<std::string>{"abc"})), typename M::size_type);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).count(Transparent<std::string>{"b"})), typename M::size_type);
+    assert(m.count(Transparent<std::string>{"alpha"}) == 1);
+    assert(m.count(Transparent<std::string>{"beta"}) == 3);
+    assert(m.count(Transparent<std::string>{"epsilon"}) == 1);
+    assert(m.count(Transparent<std::string>{"eta"}) == 2);
+    assert(m.count(Transparent<std::string>{"gamma"}) == 1);
+    assert(m.count(Transparent<std::string>{"al"}) == 0);
+    assert(m.count(Transparent<std::string>{""}) == 0);
+    assert(m.count(Transparent<std::string>{"g"}) == 0);
+  }
+  {
+    // empty
+    M m;
+    assert(m.count(Transparent<std::string>{"alpha"}) == 0);
+    assert(m.count(Transparent<std::string>{"beta"}) == 0);
+  }
+}
+
+void test() {
+  test_one<std::vector<std::string>>();
+  test_one<std::deque<std::string>>();
+  test_one<MinSequenceContainer<std::string>>();
+  test_one<std::vector<std::string, min_allocator<std::string>>>();
+
+  {
+    bool transparent_used = false;
+    TransparentComparator c(transparent_used);
+    std::flat_multiset<int, TransparentComparator> m(std::sorted_equivalent, {1, 2, 2, 2, 3, 3, 3, 3}, c);
+    assert(!transparent_used);
+    auto n = m.count(Transparent<int>{3});
+    assert(n == 4);
+    assert(transparent_used);
+  }
+  {
+    // std::string and C string literal
+    using M = std::flat_multiset<std::string, std::less<>>;
+    M m     = {"alpha", "beta", "beta", "epsilon", "eta", "gamma"};
+    auto n  = m.count("beta");
+    assert(n == 2);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range.pass.cpp
new file mode 100644
index 0000000000000..54ae27e9ba19c
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// pair<iterator,iterator>             equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  {
+    using M  = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    using R  = std::pair<typename M::iterator, typename M::iterator>;
+    using CR = std::pair<typename M::const_iterator, typename M::const_iterator>;
+    M m      = {1, 2, 2, 4, 4, 5, 5, 5, 8};
+    ASSERT_SAME_TYPE(decltype(m.equal_range(0)), R);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).equal_range(0)), CR);
+    auto begin = m.begin();
+    assert(m.equal_range(0) == std::pair(begin, begin));
+    assert(m.equal_range(1) == std::pair(begin, begin + 1));
+    assert(m.equal_range(2) == std::pair(begin + 1, begin + 3));
+    assert(m.equal_range(3) == std::pair(begin + 3, begin + 3));
+    assert(m.equal_range(4) == std::pair(begin + 3, begin + 5));
+    assert(m.equal_range(5) == std::pair(begin + 5, begin + 8));
+    assert(m.equal_range(6) == std::pair(begin + 8, begin + 8));
+    assert(m.equal_range(7) == std::pair(begin + 8, begin + 8));
+    assert(std::as_const(m).equal_range(8) == std::pair(m.cbegin() + 8, m.cbegin() + 9));
+    assert(std::as_const(m).equal_range(9) == std::pair(m.cbegin() + 9, m.cbegin() + 9));
+  }
+
+  {
+    using M  = std::flat_multiset<Key, std::greater<int>, KeyContainer>;
+    using R  = std::pair<typename M::iterator, typename M::iterator>;
+    using CR = std::pair<typename M::const_iterator, typename M::const_iterator>;
+    M m      = {1, 1, 1, 2, 4, 5, 8, 8};
+    ASSERT_SAME_TYPE(decltype(m.equal_range(0)), R);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).equal_range(0)), CR);
+    auto begin = m.begin();
+    assert(m.equal_range(0) == std::pair(begin + 8, begin + 8));
+    assert(m.equal_range(1) == std::pair(begin + 5, begin + 8));
+    assert(m.equal_range(2) == std::pair(begin + 4, begin + 5));
+    assert(m.equal_range(3) == std::pair(begin + 4, begin + 4));
+    assert(m.equal_range(4) == std::pair(begin + 3, begin + 4));
+    assert(m.equal_range(5) == std::pair(begin + 2, begin + 3));
+    assert(m.equal_range(6) == std::pair(begin + 2, begin + 2));
+    assert(m.equal_range(7) == std::pair(begin + 2, begin + 2));
+    assert(std::as_const(m).equal_range(8) == std::pair(m.cbegin(), m.cbegin() + 2));
+    assert(std::as_const(m).equal_range(9) == std::pair(m.cbegin(), m.cbegin()));
+  }
+  {
+    // empty
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m;
+    auto end = m.end();
+    assert(m.equal_range(0) == std::pair(end, end));
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range_transparent.pass.cpp
new file mode 100644
index 0000000000000..ae16ec1127f31
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/equal_range_transparent.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class K> pair<iterator,iterator>             equal_range(const K& x);
+// template<class K> pair<const_iterator,const_iterator> equal_range(const K& x) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// Constraints: The qualified-id Compare::is_transparent is valid and denotes a type.
+template <class M>
+concept CanEqualRange   = requires(M m, Transparent<int> k) { m.equal_range(k); };
+using TransparentSet    = std::flat_multiset<int, TransparentComparator>;
+using NonTransparentSet = std::flat_multiset<int, NonTransparentComparator>;
+static_assert(CanEqualRange<TransparentSet>);
+static_assert(CanEqualRange<const TransparentSet>);
+static_assert(!CanEqualRange<NonTransparentSet>);
+static_assert(!CanEqualRange<const NonTransparentSet>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, TransparentComparator, KeyContainer>;
+
+  using R  = std::pair<typename M::iterator, typename M::iterator>;
+  using CR = std::pair<typename M::const_iterator, typename M::const_iterator>;
+
+  auto test_found = [](auto&& set, const std::string& expected_key, long expected_offset, long expected_length) {
+    auto [first, last] = set.equal_range(Transparent<std::string>{expected_key});
+    assert(last - first == expected_length);
+    assert(first - set.begin() == expected_offset);
+    for (auto it = first; it != last; ++it) {
+      assert(*it == expected_key);
+    }
+  };
+
+  auto test_not_found = [](auto&& set, const std::string& expected_key, long expected_offset) {
+    auto [first, last] = set.equal_range(Transparent<std::string>{expected_key});
+    assert(first == last);
+    assert(first - set.begin() == expected_offset);
+  };
+  {
+    M m            = {"alpha", "beta", "beta", "beta", "epsilon", "eta", "eta", "eta", "eta", "gamma", "gamma"};
+    const auto& cm = m;
+    ASSERT_SAME_TYPE(decltype(m.equal_range(Transparent<std::string>{"abc"})), R);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).equal_range(Transparent<std::string>{"b"})), CR);
+
+    test_found(m, "alpha", 0, 1);
+    test_found(m, "beta", 1, 3);
+    test_found(m, "epsilon", 4, 1);
+    test_found(m, "eta", 5, 4);
+    test_found(m, "gamma", 9, 2);
+    test_found(cm, "alpha", 0, 1);
+    test_found(cm, "beta", 1, 3);
+    test_found(cm, "epsilon", 4, 1);
+    test_found(cm, "eta", 5, 4);
+    test_found(cm, "gamma", 9, 2);
+
+    test_not_found(m, "charlie", 4);
+    test_not_found(m, "aaa", 0);
+    test_not_found(m, "zzz", 11);
+    test_not_found(cm, "charlie", 4);
+    test_not_found(cm, "aaa", 0);
+    test_not_found(cm, "zzz", 11);
+  }
+  {
+    // empty
+    M m;
+    const auto& cm = m;
+    test_not_found(m, "aaa", 0);
+    test_not_found(cm, "charlie", 0);
+  }
+}
+
+void test() {
+  test_one<std::vector<std::string>>();
+  test_one<std::deque<std::string>>();
+  test_one<MinSequenceContainer<std::string>>();
+  test_one<std::vector<std::string, min_allocator<std::string>>>();
+
+  {
+    bool transparent_used = false;
+    TransparentComparator c(transparent_used);
+    std::flat_multiset<int, TransparentComparator> m(std::sorted_equivalent, {1, 2, 3, 3, 3}, c);
+    assert(!transparent_used);
+    auto p = m.equal_range(Transparent<int>{3});
+    assert(p.first != p.second);
+    assert(transparent_used);
+  }
+  {
+    // std::string and C string literal
+    using M            = std::flat_multiset<std::string, std::less<>>;
+    M m                = {"alpha", "beta", "beta", "epsilon", "eta", "gamma"};
+    auto [first, last] = m.equal_range("beta");
+    assert(first == m.begin() + 1);
+    assert(last == m.begin() + 3);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find.pass.cpp
new file mode 100644
index 0000000000000..49386a6f77fae
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, std::less<>, KeyContainer>;
+  {
+    M m = {1, 1, 2, 4, 4, 4, 4, 5, 5, 8};
+    ASSERT_SAME_TYPE(decltype(m.find(0)), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).find(0)), typename M::const_iterator);
+    assert(m.find(0) == m.end());
+    assert(m.find(1) == m.begin());
+    assert(m.find(2) == m.begin() + 2);
+    assert(m.find(3) == m.end());
+    assert(m.find(4) == m.begin() + 3);
+    assert(m.find(5) == m.begin() + 7);
+    assert(m.find(6) == m.end());
+    assert(m.find(7) == m.end());
+    assert(std::as_const(m).find(8) == m.begin() + 9);
+    assert(std::as_const(m).find(9) == m.end());
+  }
+  {
+    // empty
+    M m;
+    assert(m.find(0) == m.end());
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find_transparent.pass.cpp
new file mode 100644
index 0000000000000..9d0b75c7b52bc
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/find_transparent.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class K> iterator       find(const K& x);
+// template<class K> const_iterator find(const K& x) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// Constraints: The qualified-id Compare::is_transparent is valid and denotes a type.
+template <class M>
+concept CanFind         = requires(M m, Transparent<int> k) { m.find(k); };
+using TransparentSet    = std::flat_multiset<int, TransparentComparator>;
+using NonTransparentSet = std::flat_multiset<int, NonTransparentComparator>;
+static_assert(CanFind<TransparentSet>);
+static_assert(CanFind<const TransparentSet>);
+static_assert(!CanFind<NonTransparentSet>);
+static_assert(!CanFind<const NonTransparentSet>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, TransparentComparator, KeyContainer>;
+
+  {
+    M m = {"alpha", "alpha", "alpha", "beta", "epsilon", "epsilon", "eta", "gamma", "gamma"};
+
+    const auto& cm = m;
+    ASSERT_SAME_TYPE(decltype(m.find(Transparent<std::string>{"abc"})), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).find(Transparent<std::string>{"b"})), typename M::const_iterator);
+
+    auto test_find = [](auto&& set, const std::string& expected_key, long expected_offset) {
+      auto iter = set.find(Transparent<std::string>{expected_key});
+      assert(iter - set.begin() == expected_offset);
+    };
+
+    test_find(m, "alpha", 0);
+    test_find(m, "beta", 3);
+    test_find(m, "epsilon", 4);
+    test_find(m, "eta", 6);
+    test_find(m, "gamma", 7);
+    test_find(m, "charlie", 9);
+    test_find(m, "aaa", 9);
+    test_find(m, "zzz", 9);
+    test_find(cm, "alpha", 0);
+    test_find(cm, "beta", 3);
+    test_find(cm, "epsilon", 4);
+    test_find(cm, "eta", 6);
+    test_find(cm, "gamma", 7);
+    test_find(cm, "charlie", 9);
+    test_find(cm, "aaa", 9);
+    test_find(cm, "zzz", 9);
+  }
+  {
+    // empty
+    M m;
+    auto iter = m.find(Transparent<std::string>{"a"});
+    assert(iter == m.end());
+  }
+}
+
+void test() {
+  test_one<std::vector<std::string>>();
+  test_one<std::deque<std::string>>();
+  test_one<MinSequenceContainer<std::string>>();
+  test_one<std::vector<std::string, min_allocator<std::string>>>();
+
+  {
+    bool transparent_used = false;
+    TransparentComparator c(transparent_used);
+    std::flat_multiset<int, TransparentComparator> m(std::sorted_equivalent, {1, 2, 2, 2, 3, 3}, c);
+    assert(!transparent_used);
+    auto it = m.find(Transparent<int>{3});
+    assert(it != m.end());
+    assert(transparent_used);
+  }
+  {
+    // std::string and C string literal
+    using M = std::flat_multiset<std::string, std::less<>>;
+    M m     = {"alpha", "beta", "beta", "epsilon", "eta", "gamma"};
+    auto it = m.find("beta");
+    assert(it == m.begin() + 1);
+    auto it2 = m.find("charlie");
+    assert(it2 == m.end());
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound.pass.cpp
new file mode 100644
index 0000000000000..ba41b822fda74
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  {
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m     = {1, 2, 2, 2, 4, 4, 5, 8, 8};
+    ASSERT_SAME_TYPE(decltype(m.lower_bound(0)), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(0)), typename M::const_iterator);
+    assert(m.lower_bound(0) == m.begin());
+    assert(m.lower_bound(1) == m.begin());
+    assert(m.lower_bound(2) == m.begin() + 1);
+    assert(m.lower_bound(3) == m.begin() + 4);
+    assert(m.lower_bound(4) == m.begin() + 4);
+    assert(m.lower_bound(5) == m.begin() + 6);
+    assert(m.lower_bound(6) == m.begin() + 7);
+    assert(m.lower_bound(7) == m.begin() + 7);
+    assert(std::as_const(m).lower_bound(8) == m.begin() + 7);
+    assert(std::as_const(m).lower_bound(9) == m.end());
+  }
+  {
+    using M = std::flat_multiset<Key, std::greater<int>, KeyContainer>;
+    M m     = {1, 1, 1, 2, 2, 4, 5, 5, 5, 8};
+    ASSERT_SAME_TYPE(decltype(m.lower_bound(0)), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(0)), typename M::const_iterator);
+    assert(m.lower_bound(0) == m.end());
+    assert(m.lower_bound(1) == m.begin() + 7);
+    assert(m.lower_bound(2) == m.begin() + 5);
+    assert(m.lower_bound(3) == m.begin() + 5);
+    assert(m.lower_bound(4) == m.begin() + 4);
+    assert(m.lower_bound(5) == m.begin() + 1);
+    assert(m.lower_bound(6) == m.begin() + 1);
+    assert(m.lower_bound(7) == m.begin() + 1);
+    assert(std::as_const(m).lower_bound(8) == m.begin());
+    assert(std::as_const(m).lower_bound(9) == m.begin());
+  }
+  {
+    // empty
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m;
+    assert(m.lower_bound(0) == m.end());
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound_transparent.pass.cpp
new file mode 100644
index 0000000000000..c03fb27a7c27e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/lower_bound_transparent.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class K> iterator       lower_bound(const K& x);
+// template<class K> const_iterator lower_bound(const K& x) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// Constraints: The qualified-id Compare::is_transparent is valid and denotes a type.
+template <class M>
+concept CanLowerBound   = requires(M m, Transparent<int> k) { m.lower_bound(k); };
+using TransparentSet    = std::flat_multiset<int, TransparentComparator>;
+using NonTransparentSet = std::flat_multiset<int, NonTransparentComparator>;
+static_assert(CanLowerBound<TransparentSet>);
+static_assert(CanLowerBound<const TransparentSet>);
+static_assert(!CanLowerBound<NonTransparentSet>);
+static_assert(!CanLowerBound<const NonTransparentSet>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, TransparentComparator, KeyContainer>;
+
+  {
+    M m            = {"alpha", "alpha", "beta", "beta", "beta", "epsilon", "eta", "eta", "eta", "eta", "gamma"};
+    const auto& cm = m;
+    ASSERT_SAME_TYPE(decltype(m.lower_bound(Transparent<std::string>{"abc"})), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(Transparent<std::string>{"b"})), typename M::const_iterator);
+
+    auto test_lower_bound = [&](auto&& set, const std::string& expected_key, long expected_offset) {
+      auto iter = set.lower_bound(Transparent<std::string>{expected_key});
+      assert(iter - set.begin() == expected_offset);
+    };
+
+    test_lower_bound(m, "abc", 0);
+    test_lower_bound(m, "alpha", 0);
+    test_lower_bound(m, "beta", 2);
+    test_lower_bound(m, "bets", 5);
+    test_lower_bound(m, "charlie", 5);
+    test_lower_bound(m, "echo", 5);
+    test_lower_bound(m, "epsilon", 5);
+    test_lower_bound(m, "eta", 6);
+    test_lower_bound(m, "gamma", 10);
+    test_lower_bound(m, "golf", 11);
+    test_lower_bound(m, "zzz", 11);
+
+    test_lower_bound(cm, "abc", 0);
+    test_lower_bound(cm, "alpha", 0);
+    test_lower_bound(cm, "beta", 2);
+    test_lower_bound(cm, "bets", 5);
+    test_lower_bound(cm, "charlie", 5);
+    test_lower_bound(cm, "echo", 5);
+    test_lower_bound(cm, "epsilon", 5);
+    test_lower_bound(cm, "eta", 6);
+    test_lower_bound(cm, "gamma", 10);
+    test_lower_bound(cm, "golf", 11);
+    test_lower_bound(cm, "zzz", 11);
+  }
+  {
+    // empty
+    M m;
+    auto iter = m.lower_bound(Transparent<std::string>{"a"});
+    assert(iter == m.end());
+  }
+}
+
+void test() {
+  test_one<std::vector<std::string>>();
+  test_one<std::deque<std::string>>();
+  test_one<MinSequenceContainer<std::string>>();
+  test_one<std::vector<std::string, min_allocator<std::string>>>();
+
+  {
+    bool transparent_used = false;
+    TransparentComparator c(transparent_used);
+    std::flat_multiset<int, TransparentComparator> m(std::sorted_equivalent, {1, 2, 2, 3, 3}, c);
+    assert(!transparent_used);
+    auto it = m.lower_bound(Transparent<int>{3});
+    assert(it != m.end());
+    assert(transparent_used);
+  }
+  {
+    // std::string and C string literal
+    using M = std::flat_multiset<std::string, std::less<>>;
+    M m     = {"alpha", "beta", "beta", "epsilon", "eta", "gamma"};
+    auto it = m.lower_bound("beta");
+    assert(it == m.begin() + 1);
+    auto it2 = m.lower_bound("charlie");
+    assert(it2 == m.begin() + 3);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound.pass.cpp
new file mode 100644
index 0000000000000..7828f0500c8b9
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  {
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m     = {1, 1, 2, 2, 4, 4, 5, 5, 8, 8};
+    ASSERT_SAME_TYPE(decltype(m.upper_bound(0)), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).upper_bound(0)), typename M::const_iterator);
+    assert(m.upper_bound(0) == m.begin());
+    assert(m.upper_bound(1) == m.begin() + 2);
+    assert(m.upper_bound(2) == m.begin() + 4);
+    assert(m.upper_bound(3) == m.begin() + 4);
+    assert(m.upper_bound(4) == m.begin() + 6);
+    assert(m.upper_bound(5) == m.begin() + 8);
+    assert(m.upper_bound(6) == m.begin() + 8);
+    assert(std::as_const(m).upper_bound(7) == m.begin() + 8);
+    assert(std::as_const(m).upper_bound(8) == m.end());
+    assert(std::as_const(m).upper_bound(9) == m.end());
+  }
+
+  {
+    using M = std::flat_multiset<Key, std::greater<int>, KeyContainer>;
+    M m     = {1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 5, 5, 8, 8};
+    ASSERT_SAME_TYPE(decltype(m.upper_bound(0)), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).upper_bound(0)), typename M::const_iterator);
+    assert(m.upper_bound(0) == m.end());
+    assert(m.upper_bound(1) == m.end());
+    assert(m.upper_bound(2) == m.begin() + 12);
+    assert(m.upper_bound(3) == m.begin() + 10);
+    assert(m.upper_bound(4) == m.begin() + 10);
+    assert(m.upper_bound(5) == m.begin() + 7);
+    assert(m.upper_bound(6) == m.begin() + 2);
+    assert(m.upper_bound(7) == m.begin() + 2);
+    assert(std::as_const(m).upper_bound(8) == m.begin() + 2);
+    assert(std::as_const(m).upper_bound(9) == m.begin());
+  }
+  {
+    // empty
+    using M = std::flat_multiset<Key, std::less<>, KeyContainer>;
+    M m;
+    assert(m.upper_bound(0) == m.end());
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound_transparent.pass.cpp
new file mode 100644
index 0000000000000..de517fd7e520a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.operations/upper_bound_transparent.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// template<class K> iterator       upper_bound(const K& x);
+// template<class K> const_iterator upper_bound(const K& x) const;
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <string>
+#include <utility>
+
+#include "MinSequenceContainer.h"
+#include "../helpers.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+
+// Constraints: The qualified-id Compare::is_transparent is valid and denotes a type.
+template <class M>
+concept CanUpperBound   = requires(M m, Transparent<int> k) { m.upper_bound(k); };
+using TransparentSet    = std::flat_multiset<int, TransparentComparator>;
+using NonTransparentSet = std::flat_multiset<int, NonTransparentComparator>;
+static_assert(CanUpperBound<TransparentSet>);
+static_assert(CanUpperBound<const TransparentSet>);
+static_assert(!CanUpperBound<NonTransparentSet>);
+static_assert(!CanUpperBound<const NonTransparentSet>);
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+  using M   = std::flat_multiset<Key, TransparentComparator, KeyContainer>;
+
+  {
+    M m            = {"alpha", "alpha", "beta", "epsilon", "epsilon", "epsilon", "eta", "gamma"};
+    const auto& cm = m;
+    ASSERT_SAME_TYPE(decltype(m.lower_bound(Transparent<std::string>{"abc"})), typename M::iterator);
+    ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(Transparent<std::string>{"b"})), typename M::const_iterator);
+
+    auto test_upper_bound = [&](auto&& set, const std::string& expected_key, long expected_offset) {
+      auto iter = set.upper_bound(Transparent<std::string>{expected_key});
+      assert(iter - set.begin() == expected_offset);
+    };
+
+    test_upper_bound(m, "abc", 0);
+    test_upper_bound(m, "alpha", 2);
+    test_upper_bound(m, "beta", 3);
+    test_upper_bound(m, "bets", 3);
+    test_upper_bound(m, "charlie", 3);
+    test_upper_bound(m, "echo", 3);
+    test_upper_bound(m, "epsilon", 6);
+    test_upper_bound(m, "eta", 7);
+    test_upper_bound(m, "gamma", 8);
+    test_upper_bound(m, "golf", 8);
+    test_upper_bound(m, "zzz", 8);
+
+    test_upper_bound(cm, "abc", 0);
+    test_upper_bound(cm, "alpha", 2);
+    test_upper_bound(cm, "beta", 3);
+    test_upper_bound(cm, "bets", 3);
+    test_upper_bound(cm, "charlie", 3);
+    test_upper_bound(cm, "echo", 3);
+    test_upper_bound(cm, "epsilon", 6);
+    test_upper_bound(cm, "eta", 7);
+    test_upper_bound(cm, "gamma", 8);
+    test_upper_bound(cm, "golf", 8);
+    test_upper_bound(cm, "zzz", 8);
+  }
+  {
+    // empty
+    M m;
+    auto iter = m.upper_bound(Transparent<std::string>{"a"});
+    assert(iter == m.end());
+  }
+}
+
+void test() {
+  test_one<std::vector<std::string>>();
+  test_one<std::deque<std::string>>();
+  test_one<MinSequenceContainer<std::string>>();
+  test_one<std::vector<std::string, min_allocator<std::string>>>();
+
+  {
+    bool transparent_used = false;
+    TransparentComparator c(transparent_used);
+    std::flat_multiset<int, TransparentComparator> m(std::sorted_equivalent, {1, 1, 1, 2, 3}, c);
+    assert(!transparent_used);
+    auto it = m.upper_bound(Transparent<int>{2});
+    assert(it != m.end());
+    assert(transparent_used);
+  }
+  {
+    // std::string and C string literal
+    using M = std::flat_multiset<std::string, std::less<>>;
+    M m     = {"alpha", "beta", "beta", "epsilon", "eta", "gamma"};
+    auto it = m.upper_bound("beta");
+    assert(it == m.begin() + 3);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/helpers.h b/libcxx/test/std/containers/container.adaptors/flat.multiset/helpers.h
new file mode 100644
index 0000000000000..e7ed8a091d3be
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/helpers.h
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUPPORT_FLAT_MULTISET_HELPERS_H
+#define SUPPORT_FLAT_MULTISET_HELPERS_H
+
+#include <algorithm>
+#include <cassert>
+#include <string>
+#include <vector>
+#include <flat_set>
+
+#include "../flat_helpers.h"
+#include "test_allocator.h"
+#include "test_macros.h"
+
+template <class... Args>
+void check_invariant(const std::flat_multiset<Args...>& m) {
+  assert(std::is_sorted(m.begin(), m.end(), m.key_comp()));
+}
+
+template <class F>
+void test_emplace_exception_guarantee([[maybe_unused]] F&& emplace_function) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  using C = TransparentComparator;
+  {
+    // Throw on emplace the key, and underlying has strong exception guarantee
+    using KeyContainer = std::vector<int, test_allocator<int>>;
+    using M            = std::flat_multiset<int, C, KeyContainer>;
+
+    LIBCPP_STATIC_ASSERT(std::__container_traits<KeyContainer>::__emplacement_has_strong_exception_safety_guarantee);
+
+    test_allocator_statistics stats;
+
+    KeyContainer a({1, 1, 2, 2, 3, 4}, test_allocator<int>{&stats});
+    [[maybe_unused]] auto expected_keys = a;
+    M m(std::sorted_equivalent, std::move(a));
+
+    stats.throw_after = 1;
+    try {
+      emplace_function(m, 0);
+      assert(false);
+    } catch (const std::bad_alloc&) {
+      check_invariant(m);
+      // In libc++, the flat_multiset is unchanged
+      LIBCPP_ASSERT(m.size() == 6);
+      LIBCPP_ASSERT(std::ranges::equal(m, expected_keys));
+    }
+  }
+  {
+    // Throw on emplace the key, and underlying has no strong exception guarantee
+    using KeyContainer = EmplaceUnsafeContainer<int>;
+    using M            = std::flat_multiset<int, C, KeyContainer>;
+
+    LIBCPP_STATIC_ASSERT(!std::__container_traits<KeyContainer>::__emplacement_has_strong_exception_safety_guarantee);
+    KeyContainer a = {1, 1, 2, 2, 3, 4};
+    M m(std::sorted_equivalent, std::move(a));
+    try {
+      emplace_function(m, 0);
+      assert(false);
+    } catch (int) {
+      check_invariant(m);
+      // In libc++, the flat_multiset is cleared
+      LIBCPP_ASSERT(m.size() == 0);
+    }
+  }
+#endif
+}
+
+template <class F>
+void test_insert_range_exception_guarantee([[maybe_unused]] F&& insert_function) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  using KeyContainer = EmplaceUnsafeContainer<int>;
+  using M            = std::flat_multiset<int, std::ranges::less, KeyContainer>;
+  test_allocator_statistics stats;
+  KeyContainer a{1, 2, 3, 4};
+  M m(std::sorted_equivalent, std::move(a));
+
+  std::vector<int> newValues = {0, 1, 5, 6, 7, 8};
+  stats.throw_after          = 1;
+  try {
+    insert_function(m, newValues);
+    assert(false);
+  } catch (int) {
+    check_invariant(m);
+    // In libc++, we clear if anything goes wrong when inserting a range
+    LIBCPP_ASSERT(m.size() == 0);
+  }
+#endif
+}
+
+template <class F>
+void test_erase_exception_guarantee([[maybe_unused]] F&& erase_function) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  {
+    // key erase throws
+    using KeyContainer = ThrowOnEraseContainer<int>;
+    using M            = std::flat_multiset<int, TransparentComparator, KeyContainer>;
+
+    KeyContainer a{1, 2, 3, 4};
+    M m(std::sorted_equivalent, std::move(a));
+    try {
+      erase_function(m, 3);
+      assert(false);
+    } catch (int) {
+      check_invariant(m);
+      // In libc++, we clear if anything goes wrong when erasing
+      LIBCPP_ASSERT(m.size() == 0);
+    }
+  }
+#endif
+}
+
+#endif // SUPPORT_FLAT_MULTISET_HELPERS_H

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/incomplete_type.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/incomplete_type.pass.cpp
new file mode 100644
index 0000000000000..88aa8f5993efa
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/incomplete_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// Check that std::flat_multiset and its iterators can be instantiated with an incomplete
+// type.
+
+#include <flat_set>
+#include <vector>
+
+struct A {
+  using Set = std::flat_multiset<A>;
+  int data;
+  Set m;
+  Set::iterator it;
+  Set::const_iterator cit;
+};
+
+// Implement the operator< required in order to instantiate flat_multiset<A>
+bool operator<(A const& L, A const& R) { return L.data < R.data; }
+
+void test() { A a; }
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/op_compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/op_compare.pass.cpp
new file mode 100644
index 0000000000000..94f0f2b34abcc
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/op_compare.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <flat_set>
+
+// friend bool operator==(const flat_multiset& x, const flat_multiset& y);
+// friend synth-three-way-result<value_type>
+//   operator<=>(const flat_multiset& x, const flat_multiset& y);
+
+#include <algorithm>
+#include <cassert>
+#include <deque>
+#include <compare>
+#include <flat_set>
+#include <functional>
+#include <limits>
+#include <vector>
+
+#include "MinSequenceContainer.h"
+#include "test_macros.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "test_comparisons.h"
+#include "test_container_comparisons.h"
+
+template <class KeyContainer>
+void test_one() {
+  using Key = typename KeyContainer::value_type;
+
+  {
+    using C = std::flat_multiset<Key>;
+    C s1, s2;
+    ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::strong_ordering);
+    AssertComparisonsReturnBool<C>();
+    assert(testComparisons(C{1, 1, 2}, C{1, 1, 3}, false, true));
+    assert(testComparisons(C{1, 1}, C{1, 1}, true, false));
+    assert(testComparisons(C{1, 10}, C{2, 2}, false, true));
+    assert(testComparisons(C{}, C{1}, false, true));
+    assert(testComparisons(C{2}, C{1, 1, 1, 1, 1}, false, false));
+  }
+  {
+    // Comparisons use value_type's native operators, not the comparator
+    using C = std::flat_multiset<Key, std::greater<Key>>;
+    C s1    = {1, 1};
+    C s2    = {2, 2};
+    ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::strong_ordering);
+    AssertComparisonsReturnBool<C>();
+    assert(testComparisons(s1, s2, false, true));
+    s2 = {1, 1};
+    assert(testComparisons(s1, s2, true, false));
+    s2 = {1, 2};
+    assert(testComparisons(s1, s2, false, true));
+    s1 = {0, 1, 2};
+    assert(testComparisons(s1, s2, false, false));
+    s2 = {0, 1, 3};
+    assert(testComparisons(s1, s2, false, true));
+  }
+}
+
+void test() {
+  test_one<std::vector<int>>();
+  test_one<std::deque<int>>();
+  test_one<MinSequenceContainer<int>>();
+  test_one<std::vector<int, min_allocator<int>>>();
+
+  {
+    using C = std::flat_multiset<double>;
+    C s1    = {1};
+    C s2    = C(std::sorted_equivalent, {std::numeric_limits<double>::quiet_NaN()});
+    ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::partial_ordering);
+    AssertComparisonsReturnBool<C>();
+    assert(testComparisonsComplete(s1, s2, false, false, false));
+  }
+  {
+    // Comparisons use value_type's native operators, not the comparator
+    struct StrongComp {
+      bool operator()(double a, double b) const { return std::strong_order(a, b) < 0; }
+    };
+    using C = std::flat_multiset<double, StrongComp>;
+    C s1    = {1};
+    C s2    = {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
+    ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::partial_ordering);
+    AssertComparisonsReturnBool<C>();
+    assert(testComparisonsComplete(s1, s2, false, false, false));
+    s1 = {1, std::numeric_limits<double>::quiet_NaN(), 1};
+    s2 = {1, std::numeric_limits<double>::quiet_NaN(), 1};
+    assert(std::lexicographical_compare_three_way(s1.begin(), s1.end(), s2.begin(), s2.end(), std::strong_order) ==
+           std::strong_ordering::equal);
+    assert(s1 != s2);
+    assert((s1 <=> s2) == std::partial_ordering::unordered);
+  }
+}
+
+int main(int, char**) {
+  test();
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/types.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/types.compile.pass.cpp
new file mode 100644
index 0000000000000..f035487c9e578
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/types.compile.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// using key_type                  = Key;
+// using value_type                = Key;
+// using key_compare               = Compare;
+// using value_compare             = Compare;
+// using reference                 = value_type&;
+// using const_reference           = const value_type&;
+// using size_type                 = typename KeyContainer::size_type;
+// using 
diff erence_type           = typename KeyContainer::
diff erence_type;
+// using iterator                  = implementation-defined;  // see [container.requirements]
+// using const_iterator            = implementation-defined;  // see [container.requirements]
+// using reverse_iterator          = std::reverse_iterator<iterator>;
+// using const_reverse_iterator    = std::reverse_iterator<const_iterator>;
+// using container_type            = KeyContainer;
+
+#include <concepts>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <ranges>
+#include <string>
+#include <vector>
+#include "min_allocator.h"
+
+void test() {
+  {
+    using M = std::flat_multiset<int>;
+    static_assert(std::is_same_v<typename M::key_type, int>);
+    static_assert(std::is_same_v<typename M::value_type, int>);
+    static_assert(std::is_same_v<typename M::key_compare, std::less<int>>);
+    static_assert(std::is_same_v<typename M::value_compare, std::less<int>>);
+    static_assert(std::is_same_v<typename M::reference, int&>);
+    static_assert(std::is_same_v<typename M::const_reference, const int&>);
+    static_assert(std::is_same_v<typename M::size_type, size_t>);
+    static_assert(std::is_same_v<typename M::
diff erence_type, ptr
diff _t>);
+    static_assert(requires { typename M::iterator; });
+    static_assert(requires { typename M::const_iterator; });
+    static_assert(std::is_same_v<typename M::reverse_iterator, std::reverse_iterator<typename M::iterator>>);
+    static_assert(
+        std::is_same_v<typename M::const_reverse_iterator, std::reverse_iterator<typename M::const_iterator>>);
+    static_assert(std::is_same_v<typename M::container_type, std::vector<int>>);
+    static_assert(requires { typename M::value_compare; });
+  }
+
+  {
+    struct A {};
+    struct Compare {
+      bool operator()(const std::string&, const std::string&) const;
+    };
+    using M = std::flat_multiset<std::string, Compare, std::deque<std::string>>;
+    static_assert(std::is_same_v<typename M::key_type, std::string>);
+    static_assert(std::is_same_v<typename M::value_type, std::string>);
+    static_assert(std::is_same_v<typename M::key_compare, Compare>);
+    static_assert(std::is_same_v<typename M::value_compare, Compare>);
+    static_assert(std::is_same_v<typename M::reference, std::string&>);
+    static_assert(std::is_same_v<typename M::const_reference, const std::string&>);
+    static_assert(std::is_same_v<typename M::size_type, size_t>);
+    static_assert(std::is_same_v<typename M::
diff erence_type, ptr
diff _t>);
+    static_assert(requires { typename M::iterator; });
+    static_assert(requires { typename M::const_iterator; });
+    static_assert(std::is_same_v<typename M::reverse_iterator, std::reverse_iterator<typename M::iterator>>);
+    static_assert(
+        std::is_same_v<typename M::const_reverse_iterator, std::reverse_iterator<typename M::const_iterator>>);
+    static_assert(std::is_same_v<typename M::container_type, std::deque<std::string>>);
+  }
+  {
+    using C = std::flat_multiset<short, std::greater<long>, std::deque<short, min_allocator<short>>>;
+    static_assert(std::is_same_v<C::key_type, short>);
+    static_assert(std::is_same_v<C::value_type, short>);
+    static_assert(std::is_same_v<C::key_compare, std::greater<long>>);
+    static_assert(std::is_same_v<C::value_compare, std::greater<long>>);
+    static_assert(std::is_same_v<C::reference, short&>);
+    static_assert(std::is_same_v<C::const_reference, const short&>);
+    static_assert(std::random_access_iterator<C::iterator>);
+    static_assert(std::random_access_iterator<C::const_iterator>);
+    static_assert(std::random_access_iterator<C::reverse_iterator>);
+    static_assert(std::random_access_iterator<C::const_reverse_iterator>);
+    static_assert(std::is_same_v<C::reverse_iterator, std::reverse_iterator<C::iterator>>);
+    static_assert(std::is_same_v<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator>>);
+    // size_type is invariably size_t
+    static_assert(std::is_same_v<C::size_type, std::size_t>);
+    static_assert(std::is_same_v<C::
diff erence_type, std::ptr
diff _t>);
+    static_assert(std::is_same_v<C::container_type, std::deque<short, min_allocator<short>>>);
+  }
+}

diff  --git a/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h b/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h
index 6aed4b1cf131d..4cc720311cf01 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h
@@ -15,6 +15,7 @@
 #include <vector>
 #include <flat_set>
 
+#include "../flat_helpers.h"
 #include "test_allocator.h"
 #include "test_macros.h"
 
@@ -28,163 +29,6 @@ void check_invariant(const std::flat_set<Args...>& m) {
   assert(std::adjacent_find(m.begin(), m.end(), key_equal) == m.end());
 }
 
-struct StartsWith {
-  explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
-  StartsWith(const StartsWith&)     = delete;
-  void operator=(const StartsWith&) = delete;
-  struct Less {
-    using is_transparent = void;
-    bool operator()(const std::string& a, const std::string& b) const { return a < b; }
-    bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
-    bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
-    bool operator()(const StartsWith&, const StartsWith&) const {
-      assert(false); // should not be called
-      return false;
-    }
-  };
-
-private:
-  std::string lower_;
-  std::string upper_;
-};
-
-template <class T>
-struct CopyOnlyVector : std::vector<T> {
-  using std::vector<T>::vector;
-
-  CopyOnlyVector(const CopyOnlyVector&) = default;
-  CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
-  CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc) : CopyOnlyVector(other, alloc) {}
-
-  CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
-  CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
-};
-
-template <class T, bool ConvertibleToT = false>
-struct Transparent {
-  T t;
-
-  explicit operator T() const
-    requires ConvertibleToT
-  {
-    return t;
-  }
-};
-
-template <class T>
-using ExplicitlyConvertibleTransparent = Transparent<T, true>;
-
-template <class T>
-using NonConvertibleTransparent = Transparent<T, false>;
-
-struct TransparentComparator {
-  using is_transparent = void;
-
-  bool* transparent_used  = nullptr;
-  TransparentComparator() = default;
-  TransparentComparator(bool& used) : transparent_used(&used) {}
-
-  template <class T, bool Convertible>
-  bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
-    if (transparent_used != nullptr) {
-      *transparent_used = true;
-    }
-    return t < transparent.t;
-  }
-
-  template <class T, bool Convertible>
-  bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
-    if (transparent_used != nullptr) {
-      *transparent_used = true;
-    }
-    return transparent.t < t;
-  }
-
-  template <class T>
-  bool operator()(const T& t1, const T& t2) const {
-    return t1 < t2;
-  }
-};
-
-struct NonTransparentComparator {
-  template <class T, bool Convertible>
-  bool operator()(const T&, const Transparent<T, Convertible>&) const;
-
-  template <class T, bool Convertible>
-  bool operator()(const Transparent<T, Convertible>&, const T&) const;
-
-  template <class T>
-  bool operator()(const T&, const T&) const;
-};
-
-struct NoDefaultCtr {
-  NoDefaultCtr() = delete;
-};
-
-#ifndef TEST_HAS_NO_EXCEPTIONS
-template <class T>
-struct EmplaceUnsafeContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  template <class... Args>
-  auto emplace(Args&&... args) -> decltype(std::declval<std::vector<T>>().emplace(std::forward<Args>(args)...)) {
-    if (this->size() > 1) {
-      auto it1 = this->begin();
-      auto it2 = it1 + 1;
-      // messing up the container
-      std::iter_swap(it1, it2);
-    }
-
-    throw 42;
-  }
-
-  template <class... Args>
-  auto insert(Args&&... args) -> decltype(std::declval<std::vector<T>>().insert(std::forward<Args>(args)...)) {
-    if (this->size() > 1) {
-      auto it1 = this->begin();
-      auto it2 = it1 + 1;
-      // messing up the container
-      std::iter_swap(it1, it2);
-    }
-
-    throw 42;
-  }
-
-  template <class... Args>
-  auto insert_range(Args&&... args)
-      -> decltype(std::declval<std::vector<T>>().insert_range(std::forward<Args>(args)...)) {
-    if (this->size() > 1) {
-      auto it1 = this->begin();
-      auto it2 = it1 + 1;
-      // messing up the container
-      std::iter_swap(it1, it2);
-    }
-
-    throw 42;
-  }
-};
-
-template <class T>
-struct ThrowOnEraseContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  template <class... Args>
-  auto erase(Args&&... args) -> decltype(std::declval<std::vector<T>>().erase(std::forward<Args>(args)...)) {
-    throw 42;
-  }
-};
-
-template <class T>
-struct ThrowOnMoveContainer : std::vector<T> {
-  using std::vector<T>::vector;
-
-  ThrowOnMoveContainer(ThrowOnMoveContainer&&) { throw 42; }
-
-  ThrowOnMoveContainer& operator=(ThrowOnMoveContainer&&) { throw 42; }
-};
-
-#endif
-
 template <class F>
 void test_emplace_exception_guarantee([[maybe_unused]] F&& emplace_function) {
 #ifndef TEST_HAS_NO_EXCEPTIONS
@@ -276,32 +120,5 @@ void test_erase_exception_guarantee([[maybe_unused]] F&& erase_function) {
   }
 #endif
 }
-class Moveable {
-  int int_;
-  double double_;
-
-public:
-  Moveable() : int_(0), double_(0) {}
-  Moveable(int i, double d) : int_(i), double_(d) {}
-  Moveable(Moveable&& x) : int_(x.int_), double_(x.double_) {
-    x.int_    = -1;
-    x.double_ = -1;
-  }
-  Moveable& operator=(Moveable&& x) {
-    int_      = x.int_;
-    x.int_    = -1;
-    double_   = x.double_;
-    x.double_ = -1;
-    return *this;
-  }
-
-  Moveable(const Moveable&)            = delete;
-  Moveable& operator=(const Moveable&) = delete;
-  bool operator==(const Moveable& x) const { return int_ == x.int_ && double_ == x.double_; }
-  bool operator<(const Moveable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
-
-  int get() const { return int_; }
-  bool moved() const { return int_ == -1; }
-};
 
 #endif // TEST_STD_CONTAINERS_CONTAINER_ADAPTORS_FLAT_SET_HELPERS_H

diff  --git a/libcxx/test/std/containers/container.adaptors/flat_helpers.h b/libcxx/test/std/containers/container.adaptors/flat_helpers.h
new file mode 100644
index 0000000000000..9cd408ef960a9
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/flat_helpers.h
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_STD_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
+#define TEST_STD_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
+
+#include <vector>
+
+#include "test_macros.h"
+
+template <class T>
+struct CopyOnlyVector : std::vector<T> {
+  using std::vector<T>::vector;
+
+  CopyOnlyVector(const CopyOnlyVector&) = default;
+  CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
+  CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc) : CopyOnlyVector(other, alloc) {}
+
+  CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
+  CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
+};
+
+template <class T, bool ConvertibleToT = false>
+struct Transparent {
+  T t;
+
+  explicit operator T() const
+    requires ConvertibleToT
+  {
+    return t;
+  }
+};
+
+template <class T>
+using ConvertibleTransparent = Transparent<T, true>;
+
+template <class T>
+using ExplicitlyConvertibleTransparent = Transparent<T, true>;
+
+template <class T>
+using NonConvertibleTransparent = Transparent<T, false>;
+
+struct TransparentComparator {
+  using is_transparent = void;
+
+  bool* transparent_used  = nullptr;
+  TransparentComparator() = default;
+  TransparentComparator(bool& used) : transparent_used(&used) {}
+
+  template <class T, bool Convertible>
+  bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
+    if (transparent_used != nullptr) {
+      *transparent_used = true;
+    }
+    return t < transparent.t;
+  }
+
+  template <class T, bool Convertible>
+  bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
+    if (transparent_used != nullptr) {
+      *transparent_used = true;
+    }
+    return transparent.t < t;
+  }
+
+  template <class T>
+  bool operator()(const T& t1, const T& t2) const {
+    return t1 < t2;
+  }
+};
+
+struct NonTransparentComparator {
+  template <class T, bool Convertible>
+  bool operator()(const T&, const Transparent<T, Convertible>&) const;
+
+  template <class T, bool Convertible>
+  bool operator()(const Transparent<T, Convertible>&, const T&) const;
+
+  template <class T>
+  bool operator()(const T&, const T&) const;
+};
+
+struct NoDefaultCtr {
+  NoDefaultCtr() = delete;
+};
+
+class Moveable {
+  int int_;
+  double double_;
+
+public:
+  Moveable() : int_(0), double_(0) {}
+  Moveable(int i, double d) : int_(i), double_(d) {}
+  Moveable(Moveable&& x) : int_(x.int_), double_(x.double_) {
+    x.int_    = -1;
+    x.double_ = -1;
+  }
+  Moveable& operator=(Moveable&& x) {
+    int_      = x.int_;
+    x.int_    = -1;
+    double_   = x.double_;
+    x.double_ = -1;
+    return *this;
+  }
+
+  Moveable(const Moveable&)            = delete;
+  Moveable& operator=(const Moveable&) = delete;
+  bool operator==(const Moveable& x) const { return int_ == x.int_ && double_ == x.double_; }
+  bool operator<(const Moveable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
+
+  int get() const { return int_; }
+  bool moved() const { return int_ == -1; }
+};
+
+#ifndef TEST_HAS_NO_EXCEPTIONS
+template <class T>
+struct EmplaceUnsafeContainer : std::vector<T> {
+  using std::vector<T>::vector;
+
+  template <class... Args>
+  auto emplace(Args&&... args) -> decltype(std::declval<std::vector<T>>().emplace(std::forward<Args>(args)...)) {
+    if (this->size() > 1) {
+      auto it1 = this->begin();
+      auto it2 = it1 + 1;
+      // messing up the container
+      std::iter_swap(it1, it2);
+    }
+
+    throw 42;
+  }
+
+  template <class... Args>
+  auto insert(Args&&... args) -> decltype(std::declval<std::vector<T>>().insert(std::forward<Args>(args)...)) {
+    if (this->size() > 1) {
+      auto it1 = this->begin();
+      auto it2 = it1 + 1;
+      // messing up the container
+      std::iter_swap(it1, it2);
+    }
+
+    throw 42;
+  }
+
+  template <class... Args>
+  auto insert_range(Args&&... args)
+      -> decltype(std::declval<std::vector<T>>().insert_range(std::forward<Args>(args)...)) {
+    if (this->size() > 1) {
+      auto it1 = this->begin();
+      auto it2 = it1 + 1;
+      // messing up the container
+      std::iter_swap(it1, it2);
+    }
+
+    throw 42;
+  }
+};
+
+template <class T>
+struct ThrowOnEraseContainer : std::vector<T> {
+  using std::vector<T>::vector;
+
+  template <class... Args>
+  auto erase(Args&&... args) -> decltype(std::declval<std::vector<T>>().erase(std::forward<Args>(args)...)) {
+    throw 42;
+  }
+};
+
+template <class T>
+struct ThrowOnMoveContainer : std::vector<T> {
+  using std::vector<T>::vector;
+
+  ThrowOnMoveContainer(ThrowOnMoveContainer&&) { throw 42; }
+
+  ThrowOnMoveContainer& operator=(ThrowOnMoveContainer&&) { throw 42; }
+};
+
+#endif // TEST_HAS_NO_EXCEPTIONS
+
+#endif // TEST_STD_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
\ No newline at end of file

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/flat_set.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/flat_set.version.compile.pass.cpp
index f9d0b0a6b4e4f..1d96845288b29 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/flat_set.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/flat_set.version.compile.pass.cpp
@@ -48,32 +48,20 @@
 
 #elif TEST_STD_VER == 23
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should be defined in c++23"
-#   endif
-#   if __cpp_lib_flat_set != 202207L
-#     error "__cpp_lib_flat_set should have the value 202207L in c++23"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_flat_set
+#   error "__cpp_lib_flat_set should be defined in c++23"
+# endif
+# if __cpp_lib_flat_set != 202207L
+#   error "__cpp_lib_flat_set should have the value 202207L in c++23"
 # endif
 
 #elif TEST_STD_VER > 23
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should be defined in c++26"
-#   endif
-#   if __cpp_lib_flat_set != 202207L
-#     error "__cpp_lib_flat_set should have the value 202207L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_flat_set
+#   error "__cpp_lib_flat_set should be defined in c++26"
+# endif
+# if __cpp_lib_flat_set != 202207L
+#   error "__cpp_lib_flat_set should have the value 202207L in c++26"
 # endif
 
 #endif // TEST_STD_VER > 23

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index 07e96e53f2e93..9b318f2deabc4 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -5128,17 +5128,11 @@
 #   error "__cpp_lib_flat_map should have the value 202207L in c++23"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should be defined in c++23"
-#   endif
-#   if __cpp_lib_flat_set != 202207L
-#     error "__cpp_lib_flat_set should have the value 202207L in c++23"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_flat_set
+#   error "__cpp_lib_flat_set should be defined in c++23"
+# endif
+# if __cpp_lib_flat_set != 202207L
+#   error "__cpp_lib_flat_set should have the value 202207L in c++23"
 # endif
 
 # if !defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT
@@ -6835,17 +6829,11 @@
 #   error "__cpp_lib_flat_map should have the value 202207L in c++26"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should be defined in c++26"
-#   endif
-#   if __cpp_lib_flat_set != 202207L
-#     error "__cpp_lib_flat_set should have the value 202207L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_flat_set
-#     error "__cpp_lib_flat_set should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_flat_set
+#   error "__cpp_lib_flat_set should be defined in c++26"
+# endif
+# if __cpp_lib_flat_set != 202207L
+#   error "__cpp_lib_flat_set should have the value 202207L in c++26"
 # endif
 
 # if !defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index febfb0f739e2c..6a9c7b4ea586c 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -520,7 +520,6 @@ def add_version_header(tc):
             "name": "__cpp_lib_flat_set",
             "values": {"c++23": 202207},
             "headers": ["flat_set"],
-            "unimplemented": True,
         },
         {
             "name": "__cpp_lib_format",

diff  --git a/libcxx/utils/libcxx/test/modules.py b/libcxx/utils/libcxx/test/modules.py
index 4c4cd273be3c3..bd4fbe78c1cdc 100644
--- a/libcxx/utils/libcxx/test/modules.py
+++ b/libcxx/utils/libcxx/test/modules.py
@@ -93,7 +93,7 @@
 ExtraHeader["functional"] = "v1/__compare/compare_three_way.h$"
 
 # <flat_set> reuses some functionality defined inside <flat_map>
-ExtraHeader["flat_set"] = "v1/__flat_map/sorted_unique.h$"
+ExtraHeader["flat_set"] = "v1/__flat_map/sorted_.+.h$"
 
 # Some C compatibility headers define std::size_t, which is in <__cstddef/size_t.h>
 for header in ("cstdio", "cstdlib", "cstring", "ctime", "cuchar", "cwchar"):


        


More information about the libcxx-commits mailing list