| 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 | #include "test_macros.h" |
| 23 | |
| 24 | int main(int, char**) { |
| 25 | #if TEST_STD_VER >= 20 |
| 26 | AssertEqualityReturnBool<std::cregex_token_iterator>(); |
| 27 | |
| 28 | { |
| 29 | std::cregex_token_iterator i; |
| 30 | assert(testEquality(i, std::default_sentinel, true)); |
| 31 | } |
| 32 | |
| 33 | AssertEqualityReturnBool<std::sregex_token_iterator>(); |
| 34 | |
| 35 | { |
| 36 | std::sregex_token_iterator i; |
| 37 | assert(testEquality(i, std::default_sentinel, true)); |
| 38 | } |
| 39 | #endif |
| 40 | |
| 41 | { |
| 42 | std::regex phone_numbers("\\d{3}-\\d{4}" ); |
| 43 | const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end" ; |
| 44 | std::cregex_token_iterator i(std::begin(arr: phone_book), std::end(arr: phone_book) - 1, phone_numbers, -1); |
| 45 | assert(i != std::cregex_token_iterator()); |
| 46 | assert(!(i == std::cregex_token_iterator())); |
| 47 | std::cregex_token_iterator i2 = i; |
| 48 | assert(i2 == i); |
| 49 | assert(!(i2 != i)); |
| 50 | ++i; |
| 51 | assert(!(i2 == i)); |
| 52 | assert(i2 != i); |
| 53 | } |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |