| 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 match_results<BidirectionalIterator, Allocator> |
| 12 | |
| 13 | // const_iterator cbegin() const; |
| 14 | // const_iterator cend() const; |
| 15 | |
| 16 | #include <regex> |
| 17 | #include <cassert> |
| 18 | #include <cstddef> |
| 19 | #include "test_macros.h" |
| 20 | |
| 21 | void |
| 22 | test() |
| 23 | { |
| 24 | std::match_results<const char*> m; |
| 25 | const char s[] = "abcdefghijk" ; |
| 26 | assert(std::regex_search(s, m, std::regex("cd((e)fg)hi" ))); |
| 27 | |
| 28 | std::match_results<const char*>::const_iterator i = m.cbegin(); |
| 29 | std::match_results<const char*>::const_iterator e = m.cend(); |
| 30 | |
| 31 | assert(static_cast<std::size_t>(e - i) == m.size()); |
| 32 | for (int j = 0; i != e; ++i, ++j) |
| 33 | assert(*i == m[j]); |
| 34 | } |
| 35 | |
| 36 | int main(int, char**) |
| 37 | { |
| 38 | test(); |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |