Debian Codegraph @

libstdc++-v3/testsuite/28_regex/match_results/ctors/char/alloc.cc

raw
1 // { dg-do run { target c++11 } }
2
3 #include <regex>
4 #include <testsuite_hooks.h>
5 #include <testsuite_allocator.h>
6
7 // LWG 2195. Missing constructors for match_results
8
9 void
10 test01()
11 {
12 using Alloc = std::cmatch::allocator_type;
13 std::cmatch m1;
14 std::cmatch m2(m1, m1.get_allocator());
15 VERIFY( m2 == m1 );
16
17 static_assert( ! std::is_nothrow_constructible<std::cmatch,
18 const std::cmatch&,
19 const Alloc&>(),
20 "Allocator-extended copy ctor is potentially-throwing" );
21
22 std::cmatch m3(std::move(m1), m2.get_allocator());
23 VERIFY( m3 == m2 );
24
25 // Libstdc++ extension:
26 static_assert( std::is_nothrow_constructible<std::cmatch,
27 std::cmatch,
28 const Alloc&>(),
29 "Allocator-extended move ctor is non-throwing" );
30 }
31
32 void
33 test02()
34 {
35 using Alloc = __gnu_test::uneq_allocator<std::csub_match>;
36 using MR = std::match_results<const char*, Alloc>;
37
38 MR m1(Alloc(1));
39 MR m2(m1, Alloc(2));
40 VERIFY( m2 == m1 );
41
42 static_assert( ! std::is_nothrow_constructible<MR, const MR&, const Alloc&>(),
43 "Allocator-extended copy ctor is potentially-throwing" );
44
45 MR m3(std::move(m1), Alloc(3));
46 VERIFY( m3 == m2 );
47
48 static_assert( ! std::is_nothrow_constructible<MR, MR, const Alloc&>(),
49 "Allocator-extended move ctor is potentially-throwing" );
50 }
51
52 int main()
53 {
54 test01();
55 test02();
56 }