-
Notifications
You must be signed in to change notification settings - Fork 13.4k
/
Copy pathlwg3987.flat_set.pass.cpp
74 lines (64 loc) · 2.27 KB
/
lwg3987.flat_set.pass.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//===----------------------------------------------------------------------===//
//
// 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
// UNSUPPORTED: clang-modules-build
// <flat_set>
// In addition to being available via inclusion of the <iterator> header,
// the function templates in [iterator.range] are available when any of the following
// headers are included: <flat_set>
#include <flat_set>
#include <cassert>
#include "test_macros.h"
constexpr bool test() {
{
std::flat_set<int> m{1, 2, 3};
const auto& cm = m;
assert(std::begin(m) == m.begin());
assert(std::begin(cm) == cm.begin());
assert(std::end(m) == m.end());
assert(std::end(cm) == cm.end());
assert(std::cbegin(m) == cm.begin());
assert(std::cbegin(cm) == cm.begin());
assert(std::cend(m) == cm.end());
assert(std::cend(cm) == cm.end());
assert(std::rbegin(m) == m.rbegin());
assert(std::rbegin(cm) == cm.rbegin());
assert(std::rend(m) == cm.rend());
assert(std::rend(cm) == cm.rend());
assert(std::crbegin(m) == cm.rbegin());
assert(std::crbegin(cm) == cm.rbegin());
assert(std::crend(m) == cm.rend());
assert(std::crend(cm) == cm.rend());
assert(std::size(cm) == cm.size());
assert(std::ssize(cm) == decltype(std::ssize(m))(m.size()));
assert(std::empty(cm) == cm.empty());
}
{
int a[] = {1, 2, 3};
assert(std::begin(a) == &a[0]);
assert(std::end(a) == &a[3]);
assert(std::rbegin(a) == std::reverse_iterator<int*>(std::end(a)));
assert(std::rend(a) == std::reverse_iterator<int*>(std::begin(a)));
assert(std::size(a) == 3);
assert(std::ssize(a) == 3);
assert(!std::empty(a));
assert(std::data(a) == &a[0]);
}
{
auto a = {1, 2, 3};
assert(std::rbegin(a) == std::reverse_iterator<const int*>(std::end(a)));
assert(std::rend(a) == std::reverse_iterator<const int*>(std::begin(a)));
assert(!std::empty(a));
assert(std::data(a) == &*std::begin(a));
}
return true;
}
int main(int, char**) {
test();
return 0;
}