[rtsan] Add fork/execve interceptors (#117198)
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / iterators.common / minus.pass.cpp
blob633d15f6299a15c2d40470fdc92419786f754d1d
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // template<sized_sentinel_for<I> I2, sized_sentinel_for<I> S2>
12 // requires sized_sentinel_for<S, I2>
13 // friend iter_difference_t<I2> operator-(
14 // const common_iterator& x, const common_iterator<I2, S2>& y);
16 #include <iterator>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "types.h"
22 void test() {
23 int buffer[8] = {1, 2, 3, 4, 5, 6, 7, 8};
26 auto iter1 = random_access_iterator<int*>(buffer);
27 auto commonIter1 = std::common_iterator<decltype(iter1), sized_sentinel_type<int*>>(iter1);
28 auto commonSent1 = std::common_iterator<decltype(iter1), sized_sentinel_type<int*>>(sized_sentinel_type<int*>{buffer + 8});
29 assert(commonIter1 - commonSent1 == -8);
30 assert(commonSent1 - commonIter1 == 8);
31 assert(commonIter1 - commonIter1 == 0);
32 assert(commonSent1 - commonSent1 == 0);
35 auto iter1 = simple_iterator<int*>(buffer);
36 auto iter2 = comparable_iterator<int*>(buffer);
37 auto commonIter1 = std::common_iterator<decltype(iter1), sized_sentinel_type<int*>>(iter1);
38 auto commonIter2 = std::common_iterator<decltype(iter2), sized_sentinel_type<int*>>(iter2);
40 assert(commonIter1 - commonIter2 == 0);
43 auto iter1 = random_access_iterator<int*>(buffer);
44 const auto commonIter1 = std::common_iterator<decltype(iter1), sized_sentinel_type<int*>>(iter1);
45 const auto commonSent1 = std::common_iterator<decltype(iter1), sized_sentinel_type<int*>>(sized_sentinel_type<int*>{buffer + 8});
46 assert(commonIter1 - commonSent1 == -8);
47 assert(commonSent1 - commonIter1 == 8);
48 assert(commonIter1 - commonIter1 == 0);
49 assert(commonSent1 - commonSent1 == 0);
52 auto iter1 = simple_iterator<int*>(buffer);
53 auto iter2 = comparable_iterator<int*>(buffer);
54 const auto commonIter1 = std::common_iterator<decltype(iter1), sized_sentinel_type<int*>>(iter1);
55 const auto commonIter2 = std::common_iterator<decltype(iter2), sized_sentinel_type<int*>>(iter2);
57 assert(commonIter1 - commonIter2 == 0);
61 int main(int, char**) {
62 test();
64 return 0;