Debian Codegraph @

libcxx/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp

raw
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_iterator<BidirectionalIterator, charT, traits>
12
13 // const value_type& operator*() const;
14
15 #include <regex>
16 #include <cassert>
17 #include "test_macros.h"
18
19 int main(int, char**)
20 {
21 {
22 std::regex phone_numbers("\\d{3}-\\d{4}");
23 const char phone_book[] = "555-1234, 555-2345, 555-3456";
24 std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
25 assert(i != std::cregex_iterator());
26 assert((*i).size() == 1);
27 assert((*i).position() == 0);
28 assert((*i).str() == "555-1234");
29 ++i;
30 assert(i != std::cregex_iterator());
31 assert((*i).size() == 1);
32 assert((*i).position() == 10);
33 assert((*i).str() == "555-2345");
34 ++i;
35 assert(i != std::cregex_iterator());
36 assert((*i).size() == 1);
37 assert((*i).position() == 20);
38 assert((*i).str() == "555-3456");
39 ++i;
40 assert(i == std::cregex_iterator());
41 }
42
43 return 0;
44 }