blob: ee6e4bb930462a756a8dc7ac4c9340ac029f28f3 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// template <class OuterAlloc, class... InnerAllocs>
13// class scoped_allocator_adaptor
14
15// template <class OuterA2>
16// scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
17// InnerAllocs...>& other);
18
Howard Hinnante92c3d72010-08-19 18:39:17 +000019#include <scoped_allocator>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020#include <cassert>
21
22#include "../allocators.h"
23
24int main()
25{
Howard Hinnant73d21a42010-09-04 23:28:19 +000026#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000027
28 {
29 typedef std::scoped_allocator_adaptor<A1<double>> B;
30 typedef std::scoped_allocator_adaptor<A1<int>> A;
31 B a1(A1<int>(3));
32 A1<int>::copy_called = false;
33 A1<int>::move_called = false;
34 A a2 = a1;
35 assert(A1<int>::copy_called == true);
36 assert(a2 == a1);
37 }
38 {
39 typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
40 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
41 B a1(A1<int>(4), A2<int>(5));
42 A1<int>::copy_called = false;
43 A1<int>::move_called = false;
44 A2<int>::copy_called = false;
45 A2<int>::move_called = false;
46 A a2 = a1;
47 assert(A1<int>::copy_called == true);
48 assert(A2<int>::copy_called == true);
49 assert(a2 == a1);
50 }
51 {
52 typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
53 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
54 B a1(A1<int>(4), A2<int>(5), A3<int>(6));
55 A1<int>::copy_called = false;
56 A1<int>::move_called = false;
57 A2<int>::copy_called = false;
58 A2<int>::move_called = false;
59 A3<int>::copy_called = false;
60 A3<int>::move_called = false;
61 A a2 = a1;
62 assert(A1<int>::copy_called == true);
63 assert(A2<int>::copy_called == true);
64 assert(A3<int>::copy_called == true);
65 assert(a2 == a1);
66 }
67
Howard Hinnant73d21a42010-09-04 23:28:19 +000068#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000069}