blob: 7660f6ffa5e923d3d943c2dfc27bcb9a47b57913 [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// scoped_allocator_adaptor();
16
Howard Hinnante92c3d72010-08-19 18:39:17 +000017#include <scoped_allocator>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000018#include <cassert>
19
20#include "../allocators.h"
21
22int main()
23{
Howard Hinnant73d21a42010-09-04 23:28:19 +000024#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000025
26 {
27 typedef std::scoped_allocator_adaptor<A1<int>> A;
28 A a;
29 assert(a.outer_allocator() == A1<int>());
30 assert(a.inner_allocator() == a);
31 assert(A1<int>::copy_called == false);
32 assert(A1<int>::move_called == false);
33 }
34 {
35 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
36 A a;
37 assert(a.outer_allocator() == A1<int>());
38 assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
39 assert(A1<int>::copy_called == false);
40 assert(A1<int>::move_called == false);
41 assert(A2<int>::copy_called == false);
42 assert(A2<int>::move_called == false);
43 }
44 {
45 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
46 A a;
47 assert(a.outer_allocator() == A1<int>());
48 assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
49 assert(A1<int>::copy_called == false);
50 assert(A1<int>::move_called == false);
51 assert(A2<int>::copy_called == false);
52 assert(A2<int>::move_called == false);
53 assert(A3<int>::copy_called == false);
54 assert(A3<int>::move_called == false);
55 }
56
Howard Hinnant73d21a42010-09-04 23:28:19 +000057#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000058}