[libcxx-commits] [libcxx] [libc++] implement std::flat_set (PR #125241)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 31 11:07:08 PST 2025
================
@@ -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_set>
+
+// flat_set();
+
+#include <cassert>
+#include <deque>
+#include <flat_set>
+#include <functional>
+#include <type_traits>
+#include <vector>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+
+struct DefaultCtableComp {
+ explicit DefaultCtableComp() { default_constructed_ = true; }
+ bool operator()(int, int) const { return false; }
+ bool default_constructed_ = false;
+};
+
+int main(int, char**) {
+ {
----------------
ldionne wrote:
Instead of writing these tests inside `main()` directly, could you write them inside a `test()` function and then call the `test()` function from `main()`. I envision that we'll probably make `flat_set` `constexpr`-friendly soon ish, and defining these tests in a `test()` function will greatly reduce the diff when we do something like
```
constexpr bool test() {
// ...
}
int main() {
test();
static_assert(test());
}
```
https://github.com/llvm/llvm-project/pull/125241
More information about the libcxx-commits
mailing list