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 | // UNSUPPORTED: c++03 |
9 | // <regex> |
10 | |
11 | // class match_results<BidirectionalIterator, Allocator> |
12 | |
13 | // match_results(match_results&& m) noexcept; |
14 | // |
15 | // Additionally, the stored Allocator value is move constructed from m.get_allocator(). |
16 | |
17 | #include <regex> |
18 | #include <cassert> |
19 | #include "test_macros.h" |
20 | #include "test_allocator.h" |
21 | |
22 | template <class CharT, class Allocator> |
23 | void |
24 | test(const Allocator& a) |
25 | { |
26 | typedef std::match_results<const CharT*, Allocator> SM; |
27 | ASSERT_NOEXCEPT(SM(std::declval<SM&&>())); |
28 | |
29 | SM m0(a); |
30 | assert(m0.get_allocator() == a); |
31 | |
32 | SM m1(std::move(m0)); |
33 | assert(m1.size() == 0); |
34 | assert(!m1.ready()); |
35 | assert(m1.get_allocator() == a); |
36 | } |
37 | |
38 | int main(int, char**) |
39 | { |
40 | test_allocator_statistics alloc_stats; |
41 | test<char> (a: std::allocator<std::sub_match<const char *> >()); |
42 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
43 | test<wchar_t>(a: std::allocator<std::sub_match<const wchar_t *> >()); |
44 | #endif |
45 | |
46 | test<char> (test_allocator<std::sub_match<const char*> >(3, &alloc_stats)); |
47 | assert(alloc_stats.moved == 1); |
48 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
49 | test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3, &alloc_stats)); |
50 | assert(alloc_stats.moved == 2); |
51 | #endif |
52 | |
53 | return 0; |
54 | } |
55 | |