4684ddb6aa
- import libcxx - reduce targets to the one when compiled as a tools Change-Id: Iabb8427f80ff8e89463559a28bcb8b4f2bdbc496
55 lines
1.8 KiB
C++
55 lines
1.8 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <memory>
|
|
|
|
// template <class OuterAlloc, class... InnerAllocs>
|
|
// class scoped_allocator_adaptor
|
|
|
|
// scoped_allocator_adaptor select_on_container_copy_construction() const;
|
|
|
|
#include <scoped_allocator>
|
|
#include <cassert>
|
|
|
|
#include "../allocators.h"
|
|
|
|
int main()
|
|
{
|
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
|
|
{
|
|
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
|
A a1(A1<int>(3));
|
|
assert(a1.outer_allocator().id() == 3);
|
|
A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
|
|
assert(a2.outer_allocator().id() == 3);
|
|
}
|
|
|
|
{
|
|
typedef std::scoped_allocator_adaptor<A3<int>> A;
|
|
A a1(A3<int>(3));
|
|
assert(a1.outer_allocator().id() == 3);
|
|
A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
|
|
assert(a2.outer_allocator().id() == -1);
|
|
}
|
|
|
|
{
|
|
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
|
A a1(A1<int>(1), A2<int>(2), A3<int>(3));
|
|
assert(a1.outer_allocator().id() == 1);
|
|
assert(a1.inner_allocator().outer_allocator().id() == 2);
|
|
assert(a1.inner_allocator().inner_allocator().outer_allocator().id() == 3);
|
|
A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
|
|
assert(a2.outer_allocator().id() == 1);
|
|
assert(a2.inner_allocator().outer_allocator().id() == 2);
|
|
assert(a2.inner_allocator().inner_allocator().outer_allocator().id() == -1);
|
|
}
|
|
|
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
}
|