blob: d3bd7cc8618ef66a9b0a2fab6e13bb636fb8bff7 (
plain)
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
|
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// ADDITIONAL_COMPILE_FLAGS(clang): -Wprivate-header
#include <__cxx03/__iterator/aliasing_iterator.h>
#include <cassert>
struct NonTrivial {
int i_;
NonTrivial(int i) : i_(i) {}
NonTrivial(const NonTrivial& other) : i_(other.i_) {}
NonTrivial& operator=(const NonTrivial& other) {
i_ = other.i_;
return *this;
}
~NonTrivial() {}
};
int main(int, char**) {
{
NonTrivial arr[] = {1, 2, 3, 4};
std::__aliasing_iterator<NonTrivial*, int> iter(arr);
assert(*iter == 1);
assert(iter[0] == 1);
assert(iter[1] == 2);
++iter;
assert(*iter == 2);
assert(iter[-1] == 1);
assert(iter.__base() == arr + 1);
assert(iter == iter);
assert(iter != (iter + 1));
}
return 0;
}
|