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 | |
10 | // <regex> |
11 | |
12 | // class match_results<BidirectionalIterator, Allocator> |
13 | |
14 | // match_results& operator=(match_results&& m); |
15 | |
16 | #include <regex> |
17 | #include <cassert> |
18 | #include "test_macros.h" |
19 | #include "test_allocator.h" |
20 | |
21 | template <class CharT, class Allocator> |
22 | void |
23 | test(const Allocator& a) |
24 | { |
25 | typedef std::match_results<const CharT*, Allocator> SM; |
26 | SM m0(a); |
27 | SM m1; |
28 | |
29 | m1 = std::move(m0); |
30 | assert(m1.size() == 0); |
31 | assert(!m1.ready()); |
32 | if (std::allocator_traits<Allocator>::propagate_on_container_move_assignment::value) |
33 | assert(m1.get_allocator() == a); |
34 | else |
35 | assert(m1.get_allocator() == Allocator()); |
36 | } |
37 | |
38 | int main(int, char**) |
39 | { |
40 | test<char> (a: std::allocator<std::sub_match<const char *> >()); |
41 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
42 | test<wchar_t>(a: std::allocator<std::sub_match<const wchar_t *> >()); |
43 | #endif |
44 | |
45 | // test_allocator has POCMA -> false |
46 | test<char> (test_allocator<std::sub_match<const char*> >(3)); |
47 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
48 | test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3)); |
49 | #endif |
50 | |
51 | // other_allocator has POCMA -> true |
52 | test<char> (other_allocator<std::sub_match<const char*> >(3)); |
53 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
54 | test<wchar_t>(other_allocator<std::sub_match<const wchar_t*> >(3)); |
55 | #endif |
56 | |
57 | return 0; |
58 | } |
59 | |