57 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++039// <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 <cassert>18#include <regex>19#include <utility>20 21#include "test_macros.h"22#include "test_allocator.h"23 24template <class CharT, class Allocator>25void26test(const Allocator& a)27{28 typedef std::match_results<const CharT*, Allocator> SM;29 ASSERT_NOEXCEPT(SM(std::declval<SM&&>()));30 31 SM m0(a);32 assert(m0.get_allocator() == a);33 34 SM m1(std::move(m0));35 assert(m1.size() == 0);36 assert(!m1.ready());37 assert(m1.get_allocator() == a);38}39 40int main(int, char**)41{42 test_allocator_statistics alloc_stats;43 test<char> (std::allocator<std::sub_match<const char *> >());44#ifndef TEST_HAS_NO_WIDE_CHARACTERS45 test<wchar_t>(std::allocator<std::sub_match<const wchar_t *> >());46#endif47 48 test<char> (test_allocator<std::sub_match<const char*> >(3, &alloc_stats));49 assert(alloc_stats.moved == 1);50#ifndef TEST_HAS_NO_WIDE_CHARACTERS51 test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3, &alloc_stats));52 assert(alloc_stats.moved == 2);53#endif54 55 return 0;56}57