llvm-project/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp
Louis Dionne 31cbe0f240 [libc++] Remove the c++98 Lit feature from the test suite
C++98 and C++03 are effectively aliases as far as Clang is concerned.
As such, allowing both std=c++98 and std=c++03 as Lit parameters is
just slightly confusing, but provides no value. It's similar to allowing
both std=c++17 and std=c++1z, which we don't do.

This was discovered because we had an internal bot that ran the test
suite under both c++98 AND c++03 -- one of which is redundant.

Differential Revision: https://reviews.llvm.org/D80926
2020-06-03 09:37:22 -04:00

63 lines
1.4 KiB
C++

//===----------------------------------------------------------------------===//
//
// 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
// <set>
// class set
// node_type extract(const_iterator);
#include <set>
#include "test_macros.h"
#include "min_allocator.h"
#include "Counter.h"
template <class Container>
void test(Container& c)
{
size_t sz = c.size();
for (auto first = c.cbegin(); first != c.cend();)
{
auto key_value = *first;
typename Container::node_type t = c.extract(first++);
--sz;
assert(t.value() == key_value);
assert(t.get_allocator() == c.get_allocator());
assert(sz == c.size());
}
assert(c.size() == 0);
}
int main(int, char**)
{
{
using set_type = std::set<int>;
set_type m = {1, 2, 3, 4, 5, 6};
test(m);
}
{
std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
assert(Counter_base::gConstructed == 6);
test(m);
assert(Counter_base::gConstructed == 0);
}
{
using min_alloc_set = std::set<int, std::less<int>, min_allocator<int>>;
min_alloc_set m = {1, 2, 3, 4, 5, 6};
test(m);
}
return 0;
}