libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// template <class OuterA2>
|
||||
// scoped_allocator_adaptor(OuterA2&& outerAlloc,
|
||||
// const InnerAllocs& ...innerAllocs);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A1<int> a3(3);
|
||||
A a(a3);
|
||||
assert(a.outer_allocator() == A1<int>(3));
|
||||
assert(a.inner_allocator() == a);
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A1<int>::move_called == false);
|
||||
}
|
||||
A1<int>::copy_called = false;
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a(A1<int>(3));
|
||||
assert(a.outer_allocator() == A1<int>(3));
|
||||
assert(a.inner_allocator() == a);
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == true);
|
||||
}
|
||||
A1<int>::move_called = false;
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A1<int> a4(4);
|
||||
A a(a4, A2<int>(5));
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A1<int>::move_called == false);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(A2<int>::move_called == false);
|
||||
assert(a.outer_allocator() == A1<int>(4));
|
||||
assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
|
||||
}
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a(A1<int>(4), A2<int>(5));
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == true);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(A2<int>::move_called == false);
|
||||
assert(a.outer_allocator() == A1<int>(4));
|
||||
assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
|
||||
}
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A1<int>::move_called = false;
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A1<int> a4(4);
|
||||
A a(a4, A2<int>(5), A3<int>(6));
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A1<int>::move_called == false);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(A2<int>::move_called == false);
|
||||
assert(A3<int>::copy_called == true);
|
||||
assert(A3<int>::move_called == false);
|
||||
assert(a.outer_allocator() == A1<int>(4));
|
||||
assert((a.inner_allocator() ==
|
||||
std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
|
||||
}
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A3<int>::copy_called = false;
|
||||
A3<int>::move_called = false;
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a(A1<int>(4), A2<int>(5), A3<int>(6));
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == true);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(A2<int>::move_called == false);
|
||||
assert(A3<int>::copy_called == true);
|
||||
assert(A3<int>::move_called == false);
|
||||
assert(a.outer_allocator() == A1<int>(4));
|
||||
assert((a.inner_allocator() ==
|
||||
std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// template <class OuterA2>
|
||||
// scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
|
||||
// InnerAllocs...>& other);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<double>> B;
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
B a1(A1<int>(3));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A a2 = a1;
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
B a1(A1<int>(4), A2<int>(5));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A a2 = a1;
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
B a1(A1<int>(4), A2<int>(5), A3<int>(6));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A3<int>::copy_called = false;
|
||||
A3<int>::move_called = false;
|
||||
A a2 = a1;
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(A3<int>::copy_called == true);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// template <class OuterA2>
|
||||
// scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2,
|
||||
// InnerAllocs...>&& other);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<double>> B;
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
B a1(A1<int>(3));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A a2 = std::move(a1);
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == true);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
B a1(A1<int>(4), A2<int>(5));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A a2 = std::move(a1);
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == true);
|
||||
assert(A2<int>::copy_called == false);
|
||||
assert(A2<int>::move_called == true);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
B a1(A1<int>(4), A2<int>(5), A3<int>(6));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A3<int>::copy_called = false;
|
||||
A3<int>::move_called = false;
|
||||
A a2 = std::move(a1);
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == true);
|
||||
assert(A2<int>::copy_called == false);
|
||||
assert(A2<int>::move_called == true);
|
||||
assert(A3<int>::copy_called == false);
|
||||
assert(A3<int>::move_called == true);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a1(A1<int>(3));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A a2 = a1;
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A1<int>::move_called == false);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a1(A1<int>(4), A2<int>(5));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A a2 = a1;
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A1<int>::move_called == false);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(A2<int>::move_called == false);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a1(A1<int>(4), A2<int>(5), A3<int>(6));
|
||||
A1<int>::copy_called = false;
|
||||
A1<int>::move_called = false;
|
||||
A2<int>::copy_called = false;
|
||||
A2<int>::move_called = false;
|
||||
A3<int>::copy_called = false;
|
||||
A3<int>::move_called = false;
|
||||
A a2 = a1;
|
||||
assert(A1<int>::copy_called == true);
|
||||
assert(A1<int>::move_called == false);
|
||||
assert(A2<int>::copy_called == true);
|
||||
assert(A2<int>::move_called == false);
|
||||
assert(A3<int>::copy_called == true);
|
||||
assert(A3<int>::move_called == false);
|
||||
assert(a2 == a1);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// scoped_allocator_adaptor();
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a;
|
||||
assert(a.outer_allocator() == A1<int>());
|
||||
assert(a.inner_allocator() == a);
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == false);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a;
|
||||
assert(a.outer_allocator() == A1<int>());
|
||||
assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == false);
|
||||
assert(A2<int>::copy_called == false);
|
||||
assert(A2<int>::move_called == false);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a;
|
||||
assert(a.outer_allocator() == A1<int>());
|
||||
assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
|
||||
assert(A1<int>::copy_called == false);
|
||||
assert(A1<int>::move_called == false);
|
||||
assert(A2<int>::copy_called == false);
|
||||
assert(A2<int>::move_called == false);
|
||||
assert(A3<int>::copy_called == false);
|
||||
assert(A3<int>::move_called == false);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// pointer allocate(size_type n);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a;
|
||||
A1<int>::allocate_called = false;
|
||||
assert(a.allocate(10) == (int*)10);
|
||||
assert(A1<int>::allocate_called == true);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a;
|
||||
A1<int>::allocate_called = false;
|
||||
assert(a.allocate(10) == (int*)10);
|
||||
assert(A1<int>::allocate_called == true);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a;
|
||||
A1<int>::allocate_called = false;
|
||||
assert(a.allocate(10) == (int*)10);
|
||||
assert(A1<int>::allocate_called == true);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// pointer allocate(size_type n, const_void_pointer hint);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a;
|
||||
A1<int>::allocate_called = false;
|
||||
assert(a.allocate(10, (const void*)0) == (int*)10);
|
||||
assert(A1<int>::allocate_called == true);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a;
|
||||
A1<int>::allocate_called = false;
|
||||
assert(a.allocate(10, (const void*)10) == (int*)10);
|
||||
assert(A1<int>::allocate_called == true);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a;
|
||||
A1<int>::allocate_called = false;
|
||||
assert(a.allocate(10, (const void*)20) == (int*)10);
|
||||
assert(A1<int>::allocate_called == true);
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A2<int>> A;
|
||||
A a;
|
||||
A2<int>::allocate_called = false;
|
||||
assert(a.allocate(10, (const void*)0) == (int*)0);
|
||||
assert(A2<int>::allocate_called == true);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A2<int>, A2<int>> A;
|
||||
A a;
|
||||
A2<int>::allocate_called = false;
|
||||
assert(a.allocate(10, (const void*)10) == (int*)10);
|
||||
assert(A2<int>::allocate_called == true);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A2<int>, A2<int>, A3<int>> A;
|
||||
A a;
|
||||
A2<int>::allocate_called = false;
|
||||
assert(a.allocate(10, (const void*)20) == (int*)20);
|
||||
assert(A2<int>::allocate_called == true);
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,193 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// template <class T, class... Args> void construct(T* p, Args&&... args);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
struct B
|
||||
{
|
||||
static bool constructed;
|
||||
|
||||
typedef A1<B> allocator_type;
|
||||
|
||||
explicit B(std::allocator_arg_t, const allocator_type& a, int i)
|
||||
{
|
||||
assert(a.id() == 5);
|
||||
assert(i == 6);
|
||||
constructed = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool B::constructed = false;
|
||||
|
||||
struct C
|
||||
{
|
||||
static bool constructed;
|
||||
|
||||
typedef std::scoped_allocator_adaptor<A2<C>> allocator_type;
|
||||
|
||||
explicit C(std::allocator_arg_t, const allocator_type& a, int i)
|
||||
{
|
||||
assert(a.id() == 7);
|
||||
assert(i == 8);
|
||||
constructed = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool C::constructed = false;
|
||||
|
||||
struct D
|
||||
{
|
||||
static bool constructed;
|
||||
|
||||
typedef std::scoped_allocator_adaptor<A2<D>> allocator_type;
|
||||
|
||||
explicit D(int i, int j, const allocator_type& a)
|
||||
{
|
||||
assert(i == 1);
|
||||
assert(j == 2);
|
||||
assert(a.id() == 3);
|
||||
constructed = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool D::constructed = false;
|
||||
|
||||
struct E
|
||||
{
|
||||
static bool constructed;
|
||||
|
||||
typedef std::scoped_allocator_adaptor<A1<E>> allocator_type;
|
||||
|
||||
explicit E(int i, int j, const allocator_type& a)
|
||||
{
|
||||
assert(i == 1);
|
||||
assert(j == 2);
|
||||
assert(a.id() == 50);
|
||||
constructed = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool E::constructed = false;
|
||||
|
||||
struct F
|
||||
{
|
||||
static bool constructed;
|
||||
|
||||
typedef std::scoped_allocator_adaptor<A2<F>> allocator_type;
|
||||
|
||||
explicit F(int i, int j)
|
||||
{
|
||||
assert(i == 1);
|
||||
assert(j == 2);
|
||||
}
|
||||
|
||||
explicit F(int i, int j, const allocator_type& a)
|
||||
{
|
||||
assert(i == 1);
|
||||
assert(j == 2);
|
||||
assert(a.id() == 50);
|
||||
constructed = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool F::constructed = false;
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<std::string>> A;
|
||||
A a;
|
||||
char buf[100];
|
||||
typedef std::string S;
|
||||
S* s = (S*)buf;
|
||||
a.construct(s, 4, 'c');
|
||||
assert(*s == "cccc");
|
||||
s->~S();
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<B>> A;
|
||||
A a(A1<B>(5));
|
||||
char buf[100];
|
||||
typedef B S;
|
||||
S* s = (S*)buf;
|
||||
a.construct(s, 6);
|
||||
assert(S::constructed);
|
||||
s->~S();
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<C>> A;
|
||||
A a(A1<int>(5), A2<C>(7));
|
||||
char buf[100];
|
||||
typedef C S;
|
||||
S* s = (S*)buf;
|
||||
a.construct(s, 8);
|
||||
assert(S::constructed);
|
||||
s->~S();
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<D>> A;
|
||||
A a(A1<int>(5), A2<D>(3));
|
||||
char buf[100];
|
||||
typedef D S;
|
||||
S* s = (S*)buf;
|
||||
a.construct(s, 1, 2);
|
||||
assert(S::constructed);
|
||||
s->~S();
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A3<E>, A2<E>> K;
|
||||
typedef std::scoped_allocator_adaptor<K, A1<E>> A;
|
||||
A a(K(), A1<E>(50));
|
||||
char buf[100];
|
||||
typedef E S;
|
||||
S* s = (S*)buf;
|
||||
A3<E>::constructed = false;
|
||||
a.construct(s, 1, 2);
|
||||
assert(S::constructed);
|
||||
assert(A3<E>::constructed);
|
||||
s->~S();
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A3<F>, A2<F>> K;
|
||||
typedef std::scoped_allocator_adaptor<K, A1<F>> A;
|
||||
A a(K(), A1<F>(50));
|
||||
char buf[100];
|
||||
typedef F S;
|
||||
S* s = (S*)buf;
|
||||
A3<F>::constructed = false;
|
||||
a.construct(s, 1, 2);
|
||||
assert(!S::constructed);
|
||||
assert(A3<F>::constructed);
|
||||
s->~S();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// void deallocate(pointer p, size_type n);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a;
|
||||
a.deallocate((int*)10, 20);
|
||||
assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a;
|
||||
a.deallocate((int*)10, 20);
|
||||
assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a;
|
||||
a.deallocate((int*)10, 20);
|
||||
assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// template <class T> void destroy(T* p);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
struct B
|
||||
{
|
||||
static bool constructed;
|
||||
|
||||
B() {constructed = true;}
|
||||
~B() {constructed = false;}
|
||||
};
|
||||
|
||||
bool B::constructed = false;
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<B>> A;
|
||||
A a;
|
||||
char buf[100];
|
||||
typedef B S;
|
||||
S* s = (S*)buf;
|
||||
assert(!S::constructed);
|
||||
a.construct(s);
|
||||
assert(S::constructed);
|
||||
a.destroy(s);
|
||||
assert(!S::constructed);
|
||||
}
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A3<B>, A1<B>> A;
|
||||
A a;
|
||||
char buf[100];
|
||||
typedef B S;
|
||||
S* s = (S*)buf;
|
||||
assert(!S::constructed);
|
||||
assert(!A3<S>::constructed);
|
||||
assert(!A3<S>::destroy_called);
|
||||
a.construct(s);
|
||||
assert(S::constructed);
|
||||
assert(A3<S>::constructed);
|
||||
assert(!A3<S>::destroy_called);
|
||||
a.destroy(s);
|
||||
assert(!S::constructed);
|
||||
assert(A3<S>::constructed);
|
||||
assert(A3<S>::destroy_called);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// inner_allocator_type& inner_allocator();
|
||||
// const inner_allocator_type& inner_allocator() const;
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a(A1<int>(5));
|
||||
assert(a.inner_allocator() == a);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a(A1<int>(5), A2<int>(6));
|
||||
assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(6)));
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a(A1<int>(5), A2<int>(6), A3<int>(8));
|
||||
assert((a.inner_allocator() ==
|
||||
std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(6), A3<int>(8))));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// size_type max_size() const;
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
const A a(A1<int>(100));
|
||||
assert(a.max_size() == 100);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
const A a(A1<int>(20), A2<int>());
|
||||
assert(a.max_size() == 20);
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
const A a(A1<int>(200), A2<int>(), A3<int>());
|
||||
assert(a.max_size() == 200);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// outer_allocator_type& outer_allocator();
|
||||
// const outer_allocator_type& outer_allocator() const;
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>> A;
|
||||
A a(A1<int>(5));
|
||||
assert(a.outer_allocator() == A1<int>(5));
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
|
||||
A a(A1<int>(5), A2<int>(6));
|
||||
assert(a.outer_allocator() == A1<int>(5));
|
||||
}
|
||||
{
|
||||
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
|
||||
A a(A1<int>(5), A2<int>(6), A3<int>(8));
|
||||
assert(a.outer_allocator() == A1<int>(5));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. 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 <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
{
|
||||
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
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// typedef see below inner_allocator_type;
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::inner_allocator_type,
|
||||
std::scoped_allocator_adaptor<A1<int>>>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>>::inner_allocator_type,
|
||||
std::scoped_allocator_adaptor<A2<int>>>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::inner_allocator_type,
|
||||
std::scoped_allocator_adaptor<A2<int>, A3<int>>>::value), "");
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// typedef see below propagate_on_container_copy_assignment;
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_copy_assignment,
|
||||
std::false_type>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_copy_assignment,
|
||||
std::false_type>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_copy_assignment,
|
||||
std::true_type>::value), "");
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// typedef see below propagate_on_container_move_assignment;
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_move_assignment,
|
||||
std::false_type>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_move_assignment,
|
||||
std::true_type>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_move_assignment,
|
||||
std::true_type>::value), "");
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
|
||||
// typedef see below propagate_on_container_swap;
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_swap,
|
||||
std::false_type>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_swap,
|
||||
std::false_type>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_swap,
|
||||
std::true_type>::value), "");
|
||||
|
||||
#endif
|
||||
}
|
176
test/utilities/memory/allocator.adaptor/allocators.h
Normal file
176
test/utilities/memory/allocator.adaptor/allocators.h
Normal file
@@ -0,0 +1,176 @@
|
||||
#ifndef ALLOCATORS_H
|
||||
#define ALLOCATORS_H
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
template <class T>
|
||||
class A1
|
||||
{
|
||||
int id_;
|
||||
public:
|
||||
explicit A1(int id = 0) : id_(id) {}
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
int id() const {return id_;}
|
||||
|
||||
static bool copy_called;
|
||||
static bool move_called;
|
||||
static bool allocate_called;
|
||||
static std::pair<T*, std::size_t> deallocate_called;
|
||||
|
||||
A1(const A1& a) : id_(a.id()) {copy_called = true;}
|
||||
A1(A1&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
template <class U>
|
||||
A1(const A1<U>& a) : id_(a.id()) {copy_called = true;}
|
||||
template <class U>
|
||||
A1(A1<U>&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
T* allocate(std::size_t n)
|
||||
{
|
||||
allocate_called = true;
|
||||
return (T*)n;
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t n)
|
||||
{
|
||||
deallocate_called = std::pair<T*, std::size_t>(p, n);
|
||||
}
|
||||
|
||||
std::size_t max_size() const {return id_;}
|
||||
};
|
||||
|
||||
template <class T> bool A1<T>::copy_called = false;
|
||||
template <class T> bool A1<T>::move_called = false;
|
||||
template <class T> bool A1<T>::allocate_called = false;
|
||||
template <class T> std::pair<T*, std::size_t> A1<T>::deallocate_called;
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator==(const A1<T>& x, const A1<U>& y)
|
||||
{
|
||||
return x.id() == y.id();
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator!=(const A1<T>& x, const A1<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class A2
|
||||
{
|
||||
int id_;
|
||||
public:
|
||||
explicit A2(int id = 0) : id_(id) {}
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
typedef unsigned size_type;
|
||||
typedef int difference_type;
|
||||
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
|
||||
int id() const {return id_;}
|
||||
|
||||
static bool copy_called;
|
||||
static bool move_called;
|
||||
static bool allocate_called;
|
||||
|
||||
A2(const A2& a) : id_(a.id()) {copy_called = true;}
|
||||
A2(A2&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
T* allocate(std::size_t n, const void* hint)
|
||||
{
|
||||
allocate_called = true;
|
||||
return (T*)hint;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T> bool A2<T>::copy_called = false;
|
||||
template <class T> bool A2<T>::move_called = false;
|
||||
template <class T> bool A2<T>::allocate_called = false;
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator==(const A2<T>& x, const A2<U>& y)
|
||||
{
|
||||
return x.id() == y.id();
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator!=(const A2<T>& x, const A2<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class A3
|
||||
{
|
||||
int id_;
|
||||
public:
|
||||
explicit A3(int id = 0) : id_(id) {}
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
typedef std::true_type propagate_on_container_copy_assignment;
|
||||
typedef std::true_type propagate_on_container_swap;
|
||||
|
||||
int id() const {return id_;}
|
||||
|
||||
static bool copy_called;
|
||||
static bool move_called;
|
||||
static bool constructed;
|
||||
static bool destroy_called;
|
||||
|
||||
A3(const A3& a) : id_(a.id()) {copy_called = true;}
|
||||
A3(A3&& a) : id_(a.id()) {move_called = true;}
|
||||
|
||||
template <class U, class ...Args>
|
||||
void construct(U* p, Args&& ...args)
|
||||
{
|
||||
::new (p) U(std::forward<Args>(args)...);
|
||||
constructed = true;
|
||||
}
|
||||
|
||||
template <class U>
|
||||
void destroy(U* p)
|
||||
{
|
||||
p->~U();
|
||||
destroy_called = true;
|
||||
}
|
||||
|
||||
A3 select_on_container_copy_construction() const {return A3(-1);}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class T> bool A3<T>::copy_called = false;
|
||||
template <class T> bool A3<T>::move_called = false;
|
||||
template <class T> bool A3<T>::constructed = false;
|
||||
template <class T> bool A3<T>::destroy_called = false;
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator==(const A3<T>& x, const A3<U>& y)
|
||||
{
|
||||
return x.id() == y.id();
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
inline
|
||||
bool operator!=(const A3<T>& x, const A3<U>& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
103
test/utilities/memory/allocator.adaptor/types.pass.cpp
Normal file
103
test/utilities/memory/allocator.adaptor/types.pass.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// template <class OuterAlloc, class... InnerAllocs>
|
||||
// class scoped_allocator_adaptor
|
||||
// : public OuterAlloc
|
||||
// {
|
||||
// public:
|
||||
// typedef OuterAlloc outer_allocator_type;
|
||||
// typedef typename OuterTraits::size_type size_type;
|
||||
// typedef typename OuterTraits::difference_type difference_type;
|
||||
// typedef typename OuterTraits::pointer pointer;
|
||||
// typedef typename OuterTraits::const_pointer const_pointer;
|
||||
// typedef typename OuterTraits::void_pointer void_pointer;
|
||||
// typedef typename OuterTraits::const_void_pointer const_void_pointer;
|
||||
// };
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "allocators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _LIBCPP_MOVE
|
||||
|
||||
static_assert((std::is_base_of<
|
||||
A1<int>,
|
||||
std::scoped_allocator_adaptor<A1<int>>
|
||||
>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::outer_allocator_type,
|
||||
A1<int>>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::size_type,
|
||||
std::size_t>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::difference_type,
|
||||
std::ptrdiff_t>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::pointer,
|
||||
int*>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::const_pointer,
|
||||
const int*>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::void_pointer,
|
||||
void*>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A1<int>>::const_void_pointer,
|
||||
const void*>::value), "");
|
||||
|
||||
|
||||
static_assert((std::is_base_of<
|
||||
A2<int>,
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>
|
||||
>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>::outer_allocator_type,
|
||||
A2<int>>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>::size_type,
|
||||
unsigned>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>::difference_type,
|
||||
int>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>::pointer,
|
||||
int*>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_pointer,
|
||||
const int*>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>::void_pointer,
|
||||
void*>::value), "");
|
||||
|
||||
static_assert((std::is_same<
|
||||
std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_void_pointer,
|
||||
const void*>::value), "");
|
||||
|
||||
#endif
|
||||
}
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/memory/c.malloc/nothing_to_do.pass.cpp
Normal file
1
test/utilities/memory/c.malloc/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/memory/pointer.traits/pointer.pass.cpp
Normal file
1
test/utilities/memory/pointer.traits/pointer.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/memory/pointer.traits/pointer_to.pass.cpp
Normal file
1
test/utilities/memory/pointer.traits/pointer_to.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/memory/pointer.traits/rebind.pass.cpp
Normal file
1
test/utilities/memory/pointer.traits/rebind.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
85
test/utilities/memory/ptr.align/align.pass.cpp
Normal file
85
test/utilities/memory/ptr.align/align.pass.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// #include <memory>
|
||||
|
||||
// void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
const unsigned N = 20;
|
||||
char buf[N];
|
||||
void* r;
|
||||
void* p = &buf[0];
|
||||
std::size_t s = N;
|
||||
r = std::align(4, 10, p, s);
|
||||
assert(p == &buf[0]);
|
||||
assert(r == p);
|
||||
assert(s == N);
|
||||
|
||||
p = &buf[1];
|
||||
s = N;
|
||||
r = std::align(4, 10, p, s);
|
||||
assert(p == &buf[4]);
|
||||
assert(r == p);
|
||||
assert(s == N-3);
|
||||
|
||||
p = &buf[2];
|
||||
s = N;
|
||||
r = std::align(4, 10, p, s);
|
||||
assert(p == &buf[4]);
|
||||
assert(r == p);
|
||||
assert(s == N-2);
|
||||
|
||||
p = &buf[3];
|
||||
s = N;
|
||||
r = std::align(4, 10, p, s);
|
||||
assert(p == &buf[4]);
|
||||
assert(r == p);
|
||||
assert(s == N-1);
|
||||
|
||||
p = &buf[4];
|
||||
s = N;
|
||||
r = std::align(4, 10, p, s);
|
||||
assert(p == &buf[4]);
|
||||
assert(r == p);
|
||||
assert(s == N);
|
||||
|
||||
p = &buf[0];
|
||||
s = N;
|
||||
r = std::align(4, N, p, s);
|
||||
assert(p == &buf[0]);
|
||||
assert(r == p);
|
||||
assert(s == N);
|
||||
|
||||
p = &buf[1];
|
||||
s = N-1;
|
||||
r = std::align(4, N-4, p, s);
|
||||
assert(p == &buf[4]);
|
||||
assert(r == p);
|
||||
assert(s == N-4);
|
||||
|
||||
p = &buf[1];
|
||||
s = N-1;
|
||||
r = std::align(4, N-3, p, s);
|
||||
assert(p == &buf[1]);
|
||||
assert(r == nullptr);
|
||||
assert(s == N-1);
|
||||
|
||||
p = &buf[0];
|
||||
s = N;
|
||||
r = std::align(1, N+1, p, s);
|
||||
assert(p == &buf[0]);
|
||||
assert(r == nullptr);
|
||||
assert(s == N);
|
||||
}
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/memory/unique.ptr/deleter.h
Normal file
1
test/utilities/memory/unique.ptr/deleter.h
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
1
test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
Normal file
1
test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
@@ -0,0 +1 @@
|
||||
//===----------------------------------------------------------------------===//
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user