llvm-project
73 строки · 1.6 Кб
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// <set>
10
11// class set
12
13// template <class InputIterator>
14// set(InputIterator first, InputIterator last);
15
16#include <set>17#include <cassert>18
19#include "test_macros.h"20#include "test_iterators.h"21#include "min_allocator.h"22
23int main(int, char**)24{
25{26typedef int V;27V ar[] =28{291,301,311,322,332,342,353,363,37338};39std::set<V> m(cpp17_input_iterator<const int*>(ar),40cpp17_input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));41assert(m.size() == 3);42assert(std::distance(m.begin(), m.end()) == 3);43assert(*m.begin() == 1);44assert(*std::next(m.begin()) == 2);45assert(*std::next(m.begin(), 2) == 3);46}47#if TEST_STD_VER >= 1148{49typedef int V;50V ar[] =51{521,531,541,552,562,572,583,593,60361};62std::set<V, std::less<int>, min_allocator<int>> m(cpp17_input_iterator<const int*>(ar),63cpp17_input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));64assert(m.size() == 3);65assert(std::distance(m.begin(), m.end()) == 3);66assert(*m.begin() == 1);67assert(*std::next(m.begin()) == 2);68assert(*std::next(m.begin(), 2) == 3);69}70#endif71
72return 0;73}
74