blob: 228a01104fca0ec1f5424985871066b358c5b679 [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// pointer allocate(size_type n);
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 A1<int>::allocate_called = false;
30 assert(a.allocate(10) == (int*)10);
31 assert(A1<int>::allocate_called == true);
32 }
33 {
34 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
35 A a;
36 A1<int>::allocate_called = false;
37 assert(a.allocate(10) == (int*)10);
38 assert(A1<int>::allocate_called == true);
39 }
40 {
41 typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
42 A a;
43 A1<int>::allocate_called = false;
44 assert(a.allocate(10) == (int*)10);
45 assert(A1<int>::allocate_called == true);
46 }
47
Howard Hinnant73d21a42010-09-04 23:28:19 +000048#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000049}