__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
{
while (__begin_ != __new_begin)
- __alloc_traits::destroy(__alloc(), __begin_++);
+ __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++));
}
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
{
while (__new_last != __end_)
- __alloc_traits::destroy(__alloc(), --__end_);
+ __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_));
}
template <class _Tp, class _Allocator>
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
- : __end_cap_(0, __a)
+ : __end_cap_(nullptr, __a)
{
__first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
__begin_ = __end_ = __first_ + __start;
_LIBCPP_INLINE_VISIBILITY inline
__split_buffer<_Tp, _Allocator>::__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
- : __first_(0), __begin_(0), __end_(0), __end_cap_(0)
+ : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr)
{
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
- : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
+ : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
{
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
- : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
+ : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
{
}
__pointer_allocator;
typedef allocator_traits<__pointer_allocator> __map_traits;
typedef typename __map_traits::pointer __map_pointer;
- typedef typename __map_traits::const_pointer __map_const_pointer;
+ typedef typename __alloc_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ rebind_alloc<const_pointer>
+#else
+ rebind_alloc<const_pointer>::other
+#endif
+ __const_pointer_allocator;
+ typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer;
typedef __split_buffer<pointer, __pointer_allocator> __map;
typedef __deque_iterator<value_type, pointer, reference, __map_pointer,
typename __deque_base<_Tp, _Allocator>::const_iterator
__deque_base<_Tp, _Allocator>::begin() const _NOEXCEPT
{
- __map_const_pointer __mp = __map_.begin() + __start_ / __block_size;
+ __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size);
return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
}
__deque_base<_Tp, _Allocator>::end() const _NOEXCEPT
{
size_type __p = size() + __start_;
- __map_const_pointer __mp = __map_.begin() + __p / __block_size;
+ __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size);
return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
}
_LIBCPP_INLINE_VISIBILITY
bool __invariants() const {return __base::__invariants();}
private:
+ typedef typename __base::__map_const_pointer __map_const_pointer;
+
_LIBCPP_INLINE_VISIBILITY
static size_type __recommend_blocks(size_type __n)
{
deque<_Tp, _Allocator>::pop_front()
{
allocator_type& __a = __base::__alloc();
- __alloc_traits::destroy(__a, *(__base::__map_.begin() +
- __base::__start_ / __base::__block_size) +
- __base::__start_ % __base::__block_size);
+ __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
+ __base::__start_ / __base::__block_size) +
+ __base::__start_ % __base::__block_size));
--__base::size();
if (++__base::__start_ >= 2 * __base::__block_size)
{
{
allocator_type& __a = __base::__alloc();
size_type __p = __base::size() + __base::__start_ - 1;
- __alloc_traits::destroy(__a, *(__base::__map_.begin() +
- __p / __base::__block_size) +
- __p % __base::__block_size);
+ __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
+ __p / __base::__block_size) +
+ __p % __base::__block_size));
--__base::size();
if (__back_spare() >= 2 * __base::__block_size)
{
__fe = __fb + __bs;
}
if (__fb <= __vt && __vt < __fe)
- __vt = (const_iterator(__f.__m_iter_, __vt) -= __f - __r).__ptr_;
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) -= __f - __r).__ptr_;
__r = _VSTD::move(__fb, __fe, __r);
__n -= __bs;
__f += __bs;
__lb = __le - __bs;
}
if (__lb <= __vt && __vt < __le)
- __vt = (const_iterator(__l.__m_iter_, __vt) += __r - __l - 1).__ptr_;
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) += __r - __l - 1).__ptr_;
__r = _VSTD::move_backward(__lb, __le, __r);
__n -= __bs;
__l -= __bs - 1;
__fe = __fb + __bs;
}
if (__fb <= __vt && __vt < __fe)
- __vt = (const_iterator(__f.__m_iter_, __vt) += __r - __f).__ptr_;
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_;
for (; __fb != __fe; ++__fb, ++__r, ++__base::size())
__alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));
__n -= __bs;
__lb = __le - __bs;
}
if (__lb <= __vt && __vt < __le)
- __vt = (const_iterator(__l.__m_iter_, __vt) -= __l - __r + 1).__ptr_;
+ __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) -= __l - __r + 1).__ptr_;
while (__le != __lb)
{
__alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
int main()
{
{
- std::deque<int> c = make(10);
+ std::deque<int> c = make<std::deque<int> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+ {
+ const std::deque<int> c = make<std::deque<int> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
for (unsigned i = 0; i < 10; ++i)
assert(c[i] == i);
for (unsigned i = 0; i < 10; ++i)
assert(c.back() == 9);
}
{
- const std::deque<int> c = make(10);
+ const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
for (unsigned i = 0; i < 10; ++i)
assert(c[i] == i);
for (unsigned i = 0; i < 10; ++i)
assert(c.front() == 0);
assert(c.back() == 9);
}
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1, int size)
+test(C& c1, int size)
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
+ typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
c1.resize(size);
assert(c1.size() == size);
assert(*i == 0);
}
+template <class C>
void
testN(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
- C c1 = make(N, start);
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
test(c1, M);
}
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
- testN(rng[i], rng[j], rng[k]);
+ testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+ }
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1, int size, int x)
+test(C& c1, int size, int x)
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
+ typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
c1.resize(size, x);
assert(c1.size() == size);
assert(*i == x);
}
+template <class C>
void
testN(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
- C c1 = make(N, start);
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
test(c1, M, -10);
}
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
- testN(rng[i], rng[j], rng[k]);
+ testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+ }
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1)
+test(C& c1)
{
- std::deque<int> s = c1;
+ C s = c1;
c1.shrink_to_fit();
assert(c1 == s);
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
- C c1 = make(N, start);
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
test(c1);
}
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include "../../../test_allocator.h"
#include "../../../NotConstructible.h"
+#include "../../../min_allocator.h"
template <class T, class Allocator>
void
{
test<int>(std::allocator<int>());
test<NotConstructible>(test_allocator<NotConstructible>(3));
+#if __cplusplus >= 201103L
+ test<int>(min_allocator<int>());
+ test<NotConstructible>(min_allocator<NotConstructible>{});
+#endif
}
#include <deque>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
std::deque<int> d;
d.assign({3, 4, 5, 6});
assert(d.size() == 4);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
#include <cassert>
#include "test_iterators.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1, const std::deque<int>& c2)
+test(C& c1, const C& c2)
{
std::size_t c1_osize = c1.size();
c1.assign(c2.begin(), c2.end());
assert(c1 == c2);
}
+template <class C>
void
testN(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
- C c1 = make(N, start);
- C c2 = make(M);
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
test(c1, c2);
}
+template <class C>
void
-testI(std::deque<int>& c1, const std::deque<int>& c2)
+testI(C& c1, const C& c2)
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
+ typedef typename C::const_iterator CI;
typedef input_iterator<CI> ICI;
std::size_t c1_osize = c1.size();
c1.assign(ICI(c2.begin()), ICI(c2.end()));
assert(c1 == c2);
}
+template <class C>
void
testNI(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
- C c1 = make(N, start);
- C c2 = make(M);
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
testI(c1, c2);
}
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
- testN(rng[i], rng[j], rng[k]);
- testNI(1500, 2000, 1000);
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int, min_allocator<int>> >(1500, 2000, 1000);
+ }
+#endif
}
#include <cassert>
#include "test_iterators.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1, int size, int v)
+test(C& c1, int size, int v)
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
+ typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
c1.assign(size, v);
assert(c1.size() == size);
assert(*i == v);
}
+template <class C>
void
testN(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
- C c1 = make(N, start);
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
test(c1, M, -10);
}
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
- testN(rng[i], rng[j], rng[k]);
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ }
+#endif
}
#include <deque>
#include <cassert>
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
template <class C>
void
assert(v2.get_allocator() == other_allocator<int>(-2));
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int>>(ab, an));
+ }
+ {
+ std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+ std::deque<int, min_allocator<int> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#endif
}
#include <cassert>
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
template <class C>
void
test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)),
other_allocator<int>(4));
}
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()),
+ min_allocator<int>());
+ }
+#endif
}
#include "../../../stack_allocator.h"
#include "../../../NotConstructible.h"
+#include "../../../min_allocator.h"
template <class T, class Allocator>
void
{
test<int, std::allocator<int> >();
test<NotConstructible, stack_allocator<NotConstructible, 1> >();
+#if __cplusplus >= 201103L
+ test<int, min_allocator<int> >();
+ test<NotConstructible, min_allocator<NotConstructible> >();
+#endif
}
#include <deque>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
std::deque<int> d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(d[0] == 3);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
#include <cassert>
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
assert(d.get_allocator() == test_allocator<int>(3));
assert(d.size() == 4);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
#include "../../../stack_allocator.h"
#include "test_iterators.h"
+#include "../../../min_allocator.h"
template <class InputIterator>
void
test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an));
test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an));
test<stack_allocator<int, 4096> >(ab, an);
+#if __cplusplus >= 201103L
+ test<min_allocator<int> >(ab, an);
+#endif
}
#include "test_iterators.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
template <class InputIterator, class Allocator>
void
test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
+#if __cplusplus >= 201103L
+ test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>());
+ test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>());
+ test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
+ test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
+#endif
}
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
assert(c1.size() == 0);
assert(c3.get_allocator() == c1.get_allocator());
}
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
assert(c3.get_allocator() == A(3));
assert(c1.size() != 0);
}
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A());
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A());
+ assert(c1.size() == 0);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
assert(c1.size() == 0);
assert(c3.get_allocator() == A(5));
}
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A{});
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == A());
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <deque>
#include <cassert>
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
template <class C>
void
assert(l2 == l);
assert(l2.get_allocator() == other_allocator<int>(5));
}
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int>>(ab, an));
+ }
+ {
+ std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::deque<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
}
#include <deque>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
std::deque<int> d;
d = {3, 4, 5, 6};
assert(d.size() == 4);
assert(d[1] == 4);
assert(d[2] == 5);
assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
#include "../../../stack_allocator.h"
#include "../../../DefaultOnly.h"
+#include "../../../min_allocator.h"
template <class T, class Allocator>
void
test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
test<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
+#if __cplusplus >= 201103L
+ test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
+#endif
}
#include <cassert>
#include "../../../stack_allocator.h"
+#include "../../../min_allocator.h"
template <class T, class Allocator>
void
test<int, std::allocator<int> >(4096, 1165);
test<int, std::allocator<int> >(4097, 157);
test<int, stack_allocator<int, 4096> >(4095, 90);
+#if __cplusplus >= 201103L
+ test<int, min_allocator<int> >(4095, 90);
+#endif
}
#include <deque>
#include <cassert>
+#include "../../../min_allocator.h"
+
template <class T, class Allocator>
void
test(unsigned n, const T& x, const Allocator& a)
int main()
{
+ {
std::allocator<int> a;
test(0, 5, a);
test(1, 10, a);
test(4095, 78, a);
test(4096, 1165, a);
test(4097, 157, a);
+ }
+#if __cplusplus >= 201103L
+ {
+ min_allocator<int> a;
+ test(0, 5, a);
+ test(1, 10, a);
+ test(10, 11, a);
+ test(1023, -11, a);
+ test(1024, 25, a);
+ test(1025, 0, a);
+ test(2047, 110, a);
+ test(2048, -500, a);
+ test(2049, 654, a);
+ test(4095, 78, a);
+ test(4096, 1165, a);
+ test(4097, 157, a);
+ }
+#endif
}
#include <cassert>
#include "../../../Emplaceable.h"
+#include "../../../min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-std::deque<Emplaceable>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<Emplaceable> c(init);
+ C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(int P, std::deque<Emplaceable>& c1)
+test(int P, C& c1)
{
- typedef std::deque<Emplaceable> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5));
assert(i == c1.begin() + P);
assert(*i == Emplaceable(1, 2.5));
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<Emplaceable> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1);
}
}
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <cassert>
#include "../../../Emplaceable.h"
+#include "../../../min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-std::deque<Emplaceable>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<Emplaceable> c(init);
+ C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<Emplaceable>& c1)
+test(C& c1)
{
- typedef std::deque<Emplaceable> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.emplace_back(Emplaceable(1, 2.5));
assert(c1.size() == c1_osize + 1);
assert(*--i == Emplaceable(1, 2.5));
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<Emplaceable> C;
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(c1);
}
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <cassert>
#include "../../../Emplaceable.h"
+#include "../../../min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-std::deque<Emplaceable>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<Emplaceable> c(init);
+ C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<Emplaceable>& c1)
+test(C& c1)
{
- typedef std::deque<Emplaceable> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.emplace_front(Emplaceable(1, 2.5));
assert(c1.size() == c1_osize + 1);
assert(*i == Emplaceable(1, 2.5));
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<Emplaceable> C;
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(c1);
}
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(int P, std::deque<int>& c1)
+test(int P, C& c1)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
assert(P < c1.size());
std::size_t c1_osize = c1.size();
I i = c1.erase(c1.cbegin() + P);
assert(*i == j);
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<int> C;
int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
for (int p = 0; p < N; p += pstep)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(p, c1);
}
}
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(int P, std::deque<int>& c1, int size)
+test(int P, C& c1, int size)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
assert(P + size <= c1.size());
std::size_t c1_osize = c1.size();
I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size));
assert(*i == j);
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<int> C;
int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
for (int p = 0; p <= N; p += pstep)
{
int sstep = std::max((N - p) / std::max(std::min(N - p, 10), 1), 1);
for (int s = 0; s <= N - p; s += sstep)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(p, c1, s);
}
}
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <deque>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
std::deque<int> d(10, 1);
std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
assert(d.size() == 14);
assert(d[11] == 1);
assert(d[12] == 1);
assert(d[13] == 1);
+ }
+ {
+ std::deque<int, min_allocator<int>> d(10, 1);
+ std::deque<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
#include "test_iterators.h"
#include "../../../MoveOnly.h"
#include "../../../stack_allocator.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(int P, std::deque<int>& c1, const std::deque<int>& c2)
+test(int P, C& c1, const C& c2)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
typedef bidirectional_iterator<CI> BCI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
assert(*i == j);
}
+template <class C>
void
testN(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
test(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
test(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
test(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
test(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
test(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
test(i, c1, c2);
}
}
}
+template <class C>
void
-testI(int P, std::deque<int>& c1, const std::deque<int>& c2)
+testI(int P, C& c1, const C& c2)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
typedef input_iterator<CI> ICI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end()));
assert(*i == j);
}
+template <class C>
void
testNI(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
testI(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
testI(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
testI(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
testI(i, c1, c2);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
testI(i, c1, c2);
}
}
}
+template <class C>
void
test_move()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > c;
- typedef std::deque<MoveOnly>::const_iterator CI;
+ C c;
+ typedef typename C::const_iterator CI;
{
MoveOnly mo(0);
typedef MoveOnly* I;
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
- testN(rng[i], rng[j], rng[k]);
- testNI(1500, 2000, 1000);
- test_move();
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_move<std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > >();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+ test_move<std::deque<MoveOnly, min_allocator<MoveOnly> > >();
+ }
+#endif
}
#include <cassert>
#include "../../../MoveOnly.h"
+#include "../../../min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-std::deque<MoveOnly>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<MoveOnly> c(init);
+ C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(int P, std::deque<MoveOnly>& c1, int x)
+test(int P, C& c1, int x)
{
- typedef std::deque<MoveOnly> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, MoveOnly(x));
assert(i == c1.begin() + P);
assert(*i == MoveOnly(j));
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<MoveOnly> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(int P, std::deque<int>& c1, int size, int x)
+test(int P, C& c1, int size, int x)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, size, x);
assert(i == c1.begin() + P);
assert(*i == j);
}
+template <class C>
void
testN(int start, int N, int M)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, M, -10);
}
}
}
+template <class C>
void
self_reference_test()
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
+ typedef typename C::const_iterator CI;
for (int i = 0; i < 20; ++i)
{
for (int j = 0; j < 20; ++j)
{
- C c = make(20);
+ C c = make<C>(20);
CI it = c.cbegin() + i;
CI jt = c.cbegin() + j;
c.insert(it, 5, *jt);
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ self_reference_test<std::deque<int> >();
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
- testN(rng[i], rng[j], rng[k]);
- self_reference_test();
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ self_reference_test<std::deque<int, min_allocator<int>> >();
+ }
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(int P, std::deque<int>& c1, int x)
+test(int P, C& c1, int x)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
std::size_t c1_osize = c1.size();
CI i = c1.insert(c1.begin() + P, x);
assert(i == c1.begin() + P);
assert(*i == j);
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
for (int i = 0; i <= 3; ++i)
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
{
if (0 <= i && i <= N)
{
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(i, c1, -10);
}
}
}
+template <class C>
void
self_reference_test()
{
- typedef std::deque<int> C;
- typedef C::const_iterator CI;
+ typedef typename C::const_iterator CI;
for (int i = 0; i < 20; ++i)
{
for (int j = 0; j < 20; ++j)
{
- C c = make(20);
+ C c = make<C>(20);
CI it = c.cbegin() + i;
CI jt = c.cbegin() + j;
c.insert(it, *jt);
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
- self_reference_test();
+ testN<std::deque<int> >(rng[i], rng[j]);
+ self_reference_test<std::deque<int> >();
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ self_reference_test<std::deque<int, min_allocator<int>> >();
+ }
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1)
+test(C& c1)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.pop_back();
assert(c1.size() == c1_osize - 1);
assert(*i == j);
}
+template <class C>
void
testN(int start, int N)
{
if (N != 0)
{
- typedef std::deque<int> C;
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(c1);
}
}
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1)
+test(C& c1)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.pop_front();
assert(c1.size() == c1_osize - 1);
assert(*i == j);
}
+template <class C>
void
testN(int start, int N)
{
if (N != 0)
{
- typedef std::deque<int> C;
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(c1);
}
}
int main()
{
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void test(int size)
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
{
- std::deque<int> c = make(size, rng[j]);
- std::deque<int>::const_iterator it = c.begin();
+ C c = make<C>(size, rng[j]);
+ typename C::const_iterator it = c.begin();
for (int i = 0; i < size; ++i, ++it)
assert(*it == i);
}
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<int> >(rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
- test(rng[j]);
+ test<std::deque<int, min_allocator<int>> >(rng[j]);
+ }
+#endif
}
#include <cassert>
#include "../../../MoveOnly.h"
+#include "../../../min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-std::deque<MoveOnly>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<MoveOnly> c(init);
+ C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void test(int size)
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
{
- std::deque<MoveOnly> c = make(size, rng[j]);
- std::deque<MoveOnly>::const_iterator it = c.begin();
+ C c = make<C>(size, rng[j]);
+ typename C::const_iterator it = c.begin();
for (int i = 0; i < size; ++i, ++it)
assert(*it == MoveOnly(i));
}
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int j = 0; j < N; ++j)
- test(rng[j]);
+ test<std::deque<MoveOnly> >(rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <deque>
#include <cassert>
-std::deque<int>
+#include "../../../min_allocator.h"
+
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<int>& c1, int x)
+test(C& c1, int x)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.push_front(x);
assert(c1.size() == c1_osize + 1);
assert(*i == j);
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<int> C;
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(c1, -10);
}
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <cassert>
#include "../../../MoveOnly.h"
+#include "../../../min_allocator.h"
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-std::deque<MoveOnly>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<MoveOnly> c(init);
+ C c(init);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void
-test(std::deque<MoveOnly>& c1, int x)
+test(C& c1, int x)
{
- typedef std::deque<MoveOnly> C;
- typedef C::iterator I;
+ typedef typename C::iterator I;
std::size_t c1_osize = c1.size();
c1.push_front(MoveOnly(x));
assert(c1.size() == c1_osize + 1);
assert(*i == MoveOnly(j));
}
+template <class C>
void
testN(int start, int N)
{
- typedef std::deque<MoveOnly> C;
- C c1 = make(N, start);
+ C c1 = make<C>(N, start);
test(c1, -10);
}
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#include <cassert>
#include "test_iterators.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void testN(int start, int N)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
typedef input_iterator<CI> ICI;
- C c1 = make(N, start);
- C c2 = make(N);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
assert(std::copy(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
assert(c1 == c2);
assert(std::copy(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <cassert>
#include "test_iterators.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void testN(int start, int N)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
- C c1 = make(N, start);
- C c2 = make(N);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
assert(std::copy_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
assert(c1 == c2);
assert(std::copy_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <cassert>
#include "test_iterators.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void testN(int start, int N)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
- C c1 = make(N, start);
- C c2 = make(N);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
assert(std::move(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
assert(c1 == c2);
assert(std::move(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
}
#include <cassert>
#include "test_iterators.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void testN(int start, int N)
{
- typedef std::deque<int> C;
- typedef C::iterator I;
- typedef C::const_iterator CI;
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
typedef random_access_iterator<I> RAI;
typedef random_access_iterator<CI> RACI;
- C c1 = make(N, start);
- C c2 = make(N);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
assert(std::move_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
assert(c1 == c2);
assert(std::move_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
int main()
{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng)/sizeof(rng[0]);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
- testN(rng[i], rng[j]);
+ testN<std::deque<int, min_allocator<int> > >(rng[i], rng[j]);
+ }
+#endif
}
#include <deque>
#include <cassert>
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
-std::deque<int>
+template <class C>
+C
make(int size, int start = 0 )
{
const int b = 4096 / sizeof(int);
init *= b;
--init;
}
- std::deque<int> c(init, 0);
+ C c(init, 0);
for (int i = 0; i < init-start; ++i)
c.pop_back();
for (int i = 0; i < size; ++i)
return c;
};
+template <class C>
void testN(int start, int N, int M)
{
- typedef std::deque<int> C;
- C c1 = make(N, start);
- C c2 = make(M);
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
C c1_save = c1;
C c2_save = c2;
swap(c1, c2);
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
for (int k = 0; k < N; ++k)
- testN(rng[i], rng[j], rng[k]);
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
}
{
int a1[] = {1, 3, 7, 9, 10};
assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
assert(c2.get_allocator() == A(1));
}
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ swap(c1, c2);
+ assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ }
+#endif
}
#include <iterator>
#include <cassert>
+#include "../../min_allocator.h"
+
int main()
{
+ {
typedef std::deque<int> C;
C c;
C::iterator i;
C::const_iterator j;
j = c.cbegin();
assert(i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::deque<int, min_allocator<int>> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+#endif
}
#include "../../test_allocator.h"
#include "../../Copyable.h"
+#include "../../min_allocator.h"
template <class T, class Allocator>
void
test<Copyable, test_allocator<Copyable> >();
static_assert((std::is_same<std::deque<char>::allocator_type,
std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+ {
+ typedef std::deque<short, min_allocator<short>> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
}