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 // <regex>
10
11 // class regex_token_iterator<BidirectionalIterator, charT, traits>
12
13 // bool operator==(const regex_token_iterator& right) const;
14 // bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); } // since C++20
15 // bool operator!=(const regex_token_iterator& right) const; // generated by the compiler in C++20
16
17 #include <cassert>
18 #include <iterator>
19 #include <regex>
20
21 #include "test_comparisons.h"
22
main(int,char **)23 int main(int, char**) {
24 #if _LIBCPP_STD_VER >= 20
25 AssertEqualityReturnBool<std::cregex_token_iterator>();
26
27 {
28 std::cregex_token_iterator i;
29 assert(testEquality(i, std::default_sentinel, true));
30 }
31
32 AssertEqualityReturnBool<std::sregex_token_iterator>();
33
34 {
35 std::sregex_token_iterator i;
36 assert(testEquality(i, std::default_sentinel, true));
37 }
38 #endif
39
40 {
41 std::regex phone_numbers("\\d{3}-\\d{4}");
42 const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
43 std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book) - 1, phone_numbers, -1);
44 assert(i != std::cregex_token_iterator());
45 assert(!(i == std::cregex_token_iterator()));
46 std::cregex_token_iterator i2 = i;
47 assert(i2 == i);
48 assert(!(i2 != i));
49 ++i;
50 assert(!(i2 == i));
51 assert(i2 != i);
52 }
53
54 return 0;
55 }
56