1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
15 // void clear() noexcept;
23 #include "MinSequenceContainer.h"
24 #include "../helpers.h"
25 #include "test_macros.h"
26 #include "min_allocator.h"
31 concept NoExceptClear
= requires(T t
) {
32 { t
.clear() } noexcept
;
35 static_assert(NoExceptClear
<std::flat_map
<int, int>>);
36 #ifndef TEST_HAS_NO_EXCEPTIONS
38 NoExceptClear
<std::flat_map
<int, int, std::less
<int>, ThrowOnMoveContainer
<int>, ThrowOnMoveContainer
<int>>>);
41 template <class KeyContainer
, class ValueContainer
>
43 using Key
= typename
KeyContainer::value_type
;
44 using Value
= typename
ValueContainer::value_type
;
45 using M
= std::flat_map
<Key
, Value
, std::less
<Key
>, KeyContainer
, ValueContainer
>;
47 M m
= {{1, 2}, {2, 1}, {3, 3}, {4, 1}, {5, 0}};
48 assert(m
.size() == 5);
49 ASSERT_NOEXCEPT(m
.clear());
50 ASSERT_SAME_TYPE(decltype(m
.clear()), void);
52 assert(m
.size() == 0);
55 int main(int, char**) {
56 test
<std::vector
<int>, std::vector
<int>>();
57 test
<std::vector
<int>, std::vector
<double>>();
58 test
<std::deque
<int>, std::vector
<double>>();
59 test
<MinSequenceContainer
<int>, MinSequenceContainer
<double>>();
60 test
<std::vector
<int, min_allocator
<int>>, std::vector
<double, min_allocator
<double>>>();
61 test
<std::vector
<int, min_allocator
<int>>, std::vector
<int, min_allocator
<int>>>();