Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
//===----------------------------------------------------------------------===//
//
// 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
// template <class OuterA2>
// scoped_allocator_adaptor(OuterA2&& outerAlloc,
// const InnerAllocs& ...innerAllocs);
#include <scoped_allocator>
#include <cassert>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// 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
// template <class OuterA2>
// scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
// InnerAllocs...>& other);
#include <scoped_allocator>
#include <cassert>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,75 @@
//===----------------------------------------------------------------------===//
//
// 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
// template <class OuterA2>
// scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2,
// InnerAllocs...>&& other);
#include <scoped_allocator>
#include <cassert>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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(const scoped_allocator_adaptor& other);
#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));
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// 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();
#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 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// 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
// pointer allocate(size_type n);
#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 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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
// pointer allocate(size_type n, const_void_pointer hint);
#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 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,193 @@
//===----------------------------------------------------------------------===//
//
// 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
// template <class T, class... Args> void construct(T* p, Args&&... args);
#include <scoped_allocator>
#include <cassert>
#include <string>
#include "allocators.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// 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
// void deallocate(pointer p, size_type n);
#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 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// 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
// template <class T> void destroy(T* p);
#include <scoped_allocator>
#include <cassert>
#include <string>
#include "allocators.h"
struct B
{
static bool constructed;
B() {constructed = true;}
~B() {constructed = false;}
};
bool B::constructed = false;
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// 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
// inner_allocator_type& inner_allocator();
// const inner_allocator_type& inner_allocator() 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 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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
// size_type max_size() 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;
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// 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
// outer_allocator_type& outer_allocator();
// const outer_allocator_type& outer_allocator() 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 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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// 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
}

View File

@@ -0,0 +1,116 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
#include <scoped_allocator>
#include <cassert>
#if __cplusplus >= 201103L
// #include <memory>
//
// template <class Alloc>
// struct allocator_traits
// {
// typedef Alloc allocator_type;
// typedef typename allocator_type::value_type
// value_type;
//
// typedef Alloc::pointer | value_type* pointer;
// typedef Alloc::const_pointer
// | pointer_traits<pointer>::rebind<const value_type>
// const_pointer;
// typedef Alloc::void_pointer
// | pointer_traits<pointer>::rebind<void>
// void_pointer;
// typedef Alloc::const_void_pointer
// | pointer_traits<pointer>::rebind<const void>
// const_void_pointer;
template <typename Alloc>
void test_pointer()
{
typename std::allocator_traits<Alloc>::pointer vp;
typename std::allocator_traits<Alloc>::const_pointer cvp;
static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
}
template <typename Alloc>
void test_void_pointer()
{
typename std::allocator_traits<Alloc>::void_pointer vp;
typename std::allocator_traits<Alloc>::const_void_pointer cvp;
static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
}
struct Foo { int x; };
int main()
{
test_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
test_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
test_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
test_void_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
test_void_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
test_void_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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
// typedef see below inner_allocator_type;
#include <scoped_allocator>
#include <type_traits>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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
// typedef see below propagate_on_container_copy_assignment;
#include <scoped_allocator>
#include <type_traits>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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
// typedef see below propagate_on_container_move_assignment;
#include <scoped_allocator>
#include <type_traits>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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
// typedef see below propagate_on_container_swap;
#include <scoped_allocator>
#include <type_traits>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// 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
// template <class OuterA1, class OuterA2, class... InnerAllocs>
// bool
// operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
// const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
//
// template <class OuterA1, class OuterA2, class... InnerAllocs>
// bool
// operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
// const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
#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));
A a2 = a1;
assert(a2 == a1);
assert(!(a2 != a1));
}
{
typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
A a1(A1<int>(4), A2<int>(5));
A a2 = a1;
assert(a2 == a1);
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));
A a2 = a1;
assert(a2 == a1);
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));
A a2(A1<int>(4), A2<int>(5), A3<int>(5));
assert(a2 != a1);
assert(!(a2 == a1));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -0,0 +1,102 @@
//===----------------------------------------------------------------------===//
//
// 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
// : 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 <scoped_allocator>
#include <type_traits>
#include "allocators.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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::make_unsigned<std::ptrdiff_t>::type>::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 // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}