[libcxx-commits] [libcxx] [libc++] Implement P0429R9 `std::flat_map` (PR #98643)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 27 12:22:22 PDT 2024
================
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_map>
+
+// [[nodiscard]] bool empty() const noexcept;
+
+#include <flat_map>
+#include <cassert>
+#include <deque>
+#include <functional>
+#include <utility>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::flat_map<int, int> M;
+ M m;
+ ASSERT_SAME_TYPE(decltype(m.empty()), bool);
+ ASSERT_NOEXCEPT(m.empty());
+ assert(m.empty());
+ assert(std::as_const(m).empty());
+ m = {{1, 1}};
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+ {
+ typedef std::flat_map<int, int, std::less<int>, std::deque<int, min_allocator<int>>> M;
+ M m;
+ ASSERT_SAME_TYPE(decltype(m.empty()), bool);
+ ASSERT_NOEXCEPT(m.empty());
+ assert(m.empty());
+ assert(std::as_const(m).empty());
+ m = {{1, 1}};
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if 0
----------------
ldionne wrote:
I think this can be removed.
https://github.com/llvm/llvm-project/pull/98643
More information about the libcxx-commits
mailing list