1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++98, c++03, c++11, c++14 10 11 // <set> 12 13 // class set 14 15 // node_type extract(const_iterator); 16 17 #include <set> 18 #include "min_allocator.h" 19 #include "Counter.h" 20 21 template <class Container> 22 void test(Container& c) 23 { 24 size_t sz = c.size(); 25 26 for (auto first = c.cbegin(); first != c.cend();) 27 { 28 auto key_value = *first; 29 typename Container::node_type t = c.extract(first++); 30 --sz; 31 assert(t.value() == key_value); 32 assert(t.get_allocator() == c.get_allocator()); 33 assert(sz == c.size()); 34 } 35 36 assert(c.size() == 0); 37 } 38 39 int main() 40 { 41 { 42 using set_type = std::set<int>; 43 set_type m = {1, 2, 3, 4, 5, 6}; 44 test(m); 45 } 46 47 { 48 std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6}; 49 assert(Counter_base::gConstructed == 6); 50 test(m); 51 assert(Counter_base::gConstructed == 0); 52 } 53 54 { 55 using min_alloc_set = std::set<int, std::less<int>, min_allocator<int>>; 56 min_alloc_set m = {1, 2, 3, 4, 5, 6}; 57 test(m); 58 } 59 } 60