outer_allocator.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// template <class OuterAlloc, class... InnerAllocs>
13//   class scoped_allocator_adaptor
14
15// outer_allocator_type& outer_allocator();
16// const outer_allocator_type& outer_allocator() const;
17
18#include <scoped_allocator>
19#include <cassert>
20
21#include "../allocators.h"
22
23int main()
24{
25#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
26
27    {
28        typedef std::scoped_allocator_adaptor<A1<int>> A;
29        A a(A1<int>(5));
30        assert(a.outer_allocator() == A1<int>(5));
31    }
32    {
33        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
34        A a(A1<int>(5), A2<int>(6));
35        assert(a.outer_allocator() == A1<int>(5));
36    }
37    {
38        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
39        A a(A1<int>(5), A2<int>(6), A3<int>(8));
40        assert(a.outer_allocator() == A1<int>(5));
41    }
42
43#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
44}
45