//===----------------------------------------------------------------------===// // // 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 // // template // flat_set(InputIterator first, InputIterator last, const key_compare& comp = key_compare()); // template // flat_set(InputIterator first, InputIterator last, const Allocator& a); // template // flat_set(InputIterator first, InputIterator last, const key_compare& comp, const Allocator& a); #include #include #include #include #include #include "MinSequenceContainer.h" #include "min_allocator.h" #include "test_allocator.h" #include "test_iterators.h" #include "test_macros.h" #include "../../../test_compare.h" template constexpr void test() { int ar[] = {1, 1, 1, 2, 2, 3, 2, 3, 3}; int expected[] = {1, 2, 3}; { // flat_set(InputIterator , InputIterator) // cpp17_input_iterator using M = std::flat_set, KeyContainer>; auto m = M(cpp17_input_iterator(ar), cpp17_input_iterator(ar + 9)); assert(std::ranges::equal(m, expected)); // explicit(false) M m2 = {cpp17_input_iterator(ar), cpp17_input_iterator(ar + 9)}; assert(m2 == m); } { // flat_set(InputIterator , InputIterator) // greater using M = std::flat_set, KeyContainer>; auto m = M(cpp17_input_iterator(ar), cpp17_input_iterator(ar + 9)); assert(std::ranges::equal(m, KeyContainer{3, 2, 1})); } { // flat_set(InputIterator , InputIterator) // Test when the operands are of array type (also contiguous iterator type) using M = std::flat_set, KeyContainer>; auto m = M(ar, ar); assert(m.empty()); } { // flat_set(InputIterator , InputIterator, const key_compare&) using C = test_less; using M = std::flat_set; 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)); } } template