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// void swap(match_results& that);
14
15#include <regex>
16#include <cassert>
17#include "test_macros.h"
18
19void
20test()
21{
22 std::match_results<const char*> m1;
23 const char s[] = "abcdefghijk";
24 assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
25 std::match_results<const char*> m2;
26
27 std::match_results<const char*> m1_save = m1;
28 std::match_results<const char*> m2_save = m2;
29
30 m1.swap(m2);
31
32 assert(m1 == m2_save);
33 assert(m2 == m1_save);
34}
35
36int main(int, char**)
37{
38 test();
39
40 return 0;
41}
42

source code of libcxx/test/std/re/re.results/re.results.swap/member_swap.pass.cpp