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// difference_type position(size_type sub = 0) const;
14
15#include <regex>
16#include <cassert>
17#include "test_macros.h"
18
19void
20test()
21{
22 std::match_results<const char*> m;
23 const char s[] = "abcdefghijk";
24 assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
25 assert(m.position() == std::distance(s, m[0].first));
26 assert(m.position(0) == std::distance(s, m[0].first));
27 assert(m.position(1) == std::distance(s, m[1].first));
28 assert(m.position(2) == std::distance(s, m[2].first));
29 assert(m.position(3) == std::distance(s, m[3].first));
30 assert(m.position(4) == std::distance(s, m[4].first));
31}
32
33int main(int, char**)
34{
35 test();
36
37 return 0;
38}
39

source code of libcxx/test/std/re/re.results/re.results.acc/position.pass.cpp