forked from OSchip/llvm-project
Implement full support for non-pointer pointers in custom allocators for vector.
llvm-svn: 185093
This commit is contained in:
parent
161381e120
commit
3ec1f00b73
|
@ -333,7 +333,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
|
|||
}
|
||||
// do middle whole words
|
||||
__storage_type __nw = __n / __bits_per_word;
|
||||
_VSTD::memset(__first.__seg_, 0, __nw * sizeof(__storage_type));
|
||||
_VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
// do last partial word
|
||||
if (__n > 0)
|
||||
|
@ -363,7 +363,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
|
|||
}
|
||||
// do middle whole words
|
||||
__storage_type __nw = __n / __bits_per_word;
|
||||
_VSTD::memset(__first.__seg_, -1, __nw * sizeof(__storage_type));
|
||||
_VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
// do last partial word
|
||||
if (__n > 0)
|
||||
|
@ -430,7 +430,9 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
|
|||
// __first.__ctz_ == 0;
|
||||
// do middle words
|
||||
__storage_type __nw = __n / __bits_per_word;
|
||||
_VSTD::memmove(__result.__seg_, __first.__seg_, __nw * sizeof(__storage_type));
|
||||
_VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
|
||||
_VSTD::__to_raw_pointer(__first.__seg_),
|
||||
__nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
__result.__seg_ += __nw;
|
||||
// do last word
|
||||
|
@ -569,7 +571,9 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
|
|||
__storage_type __nw = __n / __bits_per_word;
|
||||
__result.__seg_ -= __nw;
|
||||
__last.__seg_ -= __nw;
|
||||
_VSTD::memmove(__result.__seg_, __last.__seg_, __nw * sizeof(__storage_type));
|
||||
_VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
|
||||
_VSTD::__to_raw_pointer(__last.__seg_),
|
||||
__nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
// do last word
|
||||
if (__n > 0)
|
||||
|
@ -870,6 +874,7 @@ struct __bit_array
|
|||
{
|
||||
typedef typename _Cp::difference_type difference_type;
|
||||
typedef typename _Cp::__storage_type __storage_type;
|
||||
typedef typename _Cp::__storage_pointer __storage_pointer;
|
||||
typedef typename _Cp::iterator iterator;
|
||||
static const unsigned __bits_per_word = _Cp::__bits_per_word;
|
||||
static const unsigned _Np = 4;
|
||||
|
@ -880,9 +885,15 @@ struct __bit_array
|
|||
_LIBCPP_INLINE_VISIBILITY static difference_type capacity()
|
||||
{return static_cast<difference_type>(_Np * __bits_per_word);}
|
||||
_LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__word_, 0);}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(__word_ + __size_ / __bits_per_word,
|
||||
static_cast<unsigned>(__size_ % __bits_per_word));}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator begin()
|
||||
{
|
||||
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator end()
|
||||
{
|
||||
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
|
||||
static_cast<unsigned>(__size_ % __bits_per_word));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Cp>
|
||||
|
|
|
@ -1135,7 +1135,14 @@ public:
|
|||
#endif
|
||||
return *__i;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return &(operator*());}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
"Attempted to dereference a non-dereferenceable iterator");
|
||||
#endif
|
||||
return (pointer)&reinterpret_cast<const volatile char&>(*__i);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
|
|
@ -365,12 +365,7 @@ protected:
|
|||
{return static_cast<size_type>(__end_cap() - __begin_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last) _NOEXCEPT
|
||||
{__destruct_at_end(__new_last, false_type());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last, false_type) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last, true_type) _NOEXCEPT;
|
||||
void __destruct_at_end(pointer __new_last) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __copy_assign_alloc(const __vector_base& __c)
|
||||
|
@ -437,43 +432,35 @@ private:
|
|||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
void
|
||||
__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, false_type) _NOEXCEPT
|
||||
__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
|
||||
{
|
||||
while (__new_last != __end_)
|
||||
__alloc_traits::destroy(__alloc(), const_cast<pointer>(--__end_));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
void
|
||||
__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, true_type) _NOEXCEPT
|
||||
{
|
||||
__end_ = const_cast<pointer>(__new_last);
|
||||
__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
__vector_base<_Tp, _Allocator>::__vector_base()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||
: __begin_(0),
|
||||
__end_(0),
|
||||
__end_cap_(0)
|
||||
: __begin_(nullptr),
|
||||
__end_(nullptr),
|
||||
__end_cap_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
__vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
__end_(0),
|
||||
__end_cap_(0, __a)
|
||||
: __begin_(nullptr),
|
||||
__end_(nullptr),
|
||||
__end_cap_(nullptr, __a)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__vector_base<_Tp, _Allocator>::~__vector_base()
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
{
|
||||
clear();
|
||||
__alloc_traits::deallocate(__alloc(), __begin_, capacity());
|
||||
|
@ -797,7 +784,7 @@ private:
|
|||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
|
||||
void __move_assign(vector& __c, false_type);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last) _NOEXCEPT
|
||||
void __destruct_at_end(pointer __new_last) _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__c_node* __c = __get_db()->__find_c_and_lock(this);
|
||||
|
@ -878,11 +865,11 @@ template <class _Tp, class _Allocator>
|
|||
void
|
||||
vector<_Tp, _Allocator>::deallocate() _NOEXCEPT
|
||||
{
|
||||
if (this->__begin_ != 0)
|
||||
if (this->__begin_ != nullptr)
|
||||
{
|
||||
clear();
|
||||
__alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity());
|
||||
this->__begin_ = this->__end_ = this->__end_cap() = 0;
|
||||
this->__begin_ = this->__end_ = this->__end_cap() = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1171,7 +1158,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
|
|||
this->__begin_ = __x.__begin_;
|
||||
this->__end_ = __x.__end_;
|
||||
this->__end_cap() = __x.__end_cap();
|
||||
__x.__begin_ = __x.__end_ = __x.__end_cap() = 0;
|
||||
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
|
@ -1597,7 +1584,8 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
|
|||
#endif
|
||||
_LIBCPP_ASSERT(__position != end(),
|
||||
"vector::erase(iterator) called with a non-dereferenceable iterator");
|
||||
pointer __p = const_cast<pointer>(&*__position);
|
||||
difference_type __ps = __position - cbegin();
|
||||
pointer __p = this->__begin_ + __ps;
|
||||
iterator __r = __make_iter(__p);
|
||||
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
|
||||
return __r;
|
||||
|
@ -1943,9 +1931,9 @@ template <class _Tp, class _Allocator>
|
|||
bool
|
||||
vector<_Tp, _Allocator>::__invariants() const
|
||||
{
|
||||
if (this->__begin_ == 0)
|
||||
if (this->__begin_ == nullptr)
|
||||
{
|
||||
if (this->__end_ != 0 || this->__end_cap() != 0)
|
||||
if (this->__end_ != nullptr || this->__end_cap() != nullptr)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -2307,7 +2295,7 @@ private:
|
|||
{return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
|
||||
{return iterator(const_cast<__storage_pointer>(__p.__seg_), __p.__ctz_);}
|
||||
{return begin() + (__p - cbegin());}
|
||||
#endif // _LIBCPP_DEBUG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -2414,11 +2402,11 @@ template <class _Allocator>
|
|||
void
|
||||
vector<bool, _Allocator>::deallocate() _NOEXCEPT
|
||||
{
|
||||
if (this->__begin_ != 0)
|
||||
if (this->__begin_ != nullptr)
|
||||
{
|
||||
__storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
|
||||
__invalidate_all_iterators();
|
||||
this->__begin_ = 0;
|
||||
this->__begin_ = nullptr;
|
||||
this->__size_ = this->__cap() = 0;
|
||||
}
|
||||
}
|
||||
|
@ -2481,7 +2469,7 @@ template <class _Allocator>
|
|||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
vector<bool, _Allocator>::vector()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
|
@ -2490,7 +2478,7 @@ vector<bool, _Allocator>::vector()
|
|||
template <class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
vector<bool, _Allocator>::vector(const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
|
@ -2498,7 +2486,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
|
|||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(size_type __n)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
|
@ -2511,7 +2499,7 @@ vector<bool, _Allocator>::vector(size_type __n)
|
|||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
|
@ -2524,7 +2512,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
|
|||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
|
@ -2540,7 +2528,7 @@ template <class _InputIterator>
|
|||
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
|
||||
typename enable_if<__is_input_iterator <_InputIterator>::value &&
|
||||
!__is_forward_iterator<_InputIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
|
@ -2554,7 +2542,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
__storage_traits::deallocate(__alloc(), __begin_, __cap());
|
||||
__invalidate_all_iterators();
|
||||
throw;
|
||||
|
@ -2567,7 +2555,7 @@ template <class _InputIterator>
|
|||
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
|
||||
typename enable_if<__is_input_iterator <_InputIterator>::value &&
|
||||
!__is_forward_iterator<_InputIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
|
@ -2581,7 +2569,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
__storage_traits::deallocate(__alloc(), __begin_, __cap());
|
||||
__invalidate_all_iterators();
|
||||
throw;
|
||||
|
@ -2593,7 +2581,7 @@ template <class _Allocator>
|
|||
template <class _ForwardIterator>
|
||||
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
|
||||
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
|
@ -2609,7 +2597,7 @@ template <class _Allocator>
|
|||
template <class _ForwardIterator>
|
||||
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
|
||||
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
|
@ -2625,7 +2613,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
|
|||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
|
@ -2639,7 +2627,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
|
|||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
|
@ -2656,7 +2644,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
|
|||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::~vector()
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
__storage_traits::deallocate(__alloc(), __begin_, __cap());
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
__invalidate_all_iterators();
|
||||
|
@ -2665,7 +2653,7 @@ vector<bool, _Allocator>::~vector()
|
|||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(const vector& __v)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc()))
|
||||
{
|
||||
|
@ -2678,7 +2666,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
|
|||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, __a)
|
||||
{
|
||||
|
@ -2720,14 +2708,14 @@ vector<bool, _Allocator>::vector(vector&& __v)
|
|||
__size_(__v.__size_),
|
||||
__cap_alloc_(__v.__cap_alloc_)
|
||||
{
|
||||
__v.__begin_ = 0;
|
||||
__v.__begin_ = nullptr;
|
||||
__v.__size_ = 0;
|
||||
__v.__cap() = 0;
|
||||
}
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, __a)
|
||||
{
|
||||
|
@ -3123,7 +3111,7 @@ template <class _Allocator>
|
|||
bool
|
||||
vector<bool, _Allocator>::__invariants() const
|
||||
{
|
||||
if (this->__begin_ == 0)
|
||||
if (this->__begin_ == nullptr)
|
||||
{
|
||||
if (this->__size_ != 0 || this->__cap() != 0)
|
||||
return false;
|
||||
|
|
|
@ -11,10 +11,6 @@ template <> class min_pointer<void>;
|
|||
template <> class min_pointer<const void>;
|
||||
template <class T> class min_allocator;
|
||||
|
||||
template <class T>
|
||||
bool
|
||||
operator==(min_pointer<T> x, min_pointer<T> y);
|
||||
|
||||
template <>
|
||||
class min_pointer<const void>
|
||||
{
|
||||
|
@ -27,7 +23,8 @@ public:
|
|||
|
||||
explicit operator bool() const {return ptr_ != nullptr;}
|
||||
|
||||
template <class U> friend bool operator==(min_pointer<U>, min_pointer<U>);
|
||||
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
|
||||
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
|
||||
template <class U> friend class min_pointer;
|
||||
};
|
||||
|
||||
|
@ -48,7 +45,8 @@ public:
|
|||
|
||||
explicit operator bool() const {return ptr_ != nullptr;}
|
||||
|
||||
template <class U> friend bool operator==(min_pointer<U>, min_pointer<U>);
|
||||
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
|
||||
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
|
||||
template <class U> friend class min_pointer;
|
||||
};
|
||||
|
||||
|
@ -116,7 +114,8 @@ public:
|
|||
|
||||
static min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));}
|
||||
|
||||
template <class U> friend bool operator==(min_pointer<U>, min_pointer<U>);
|
||||
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
|
||||
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
|
||||
template <class U> friend class min_pointer;
|
||||
template <class U> friend class min_allocator;
|
||||
};
|
||||
|
@ -186,26 +185,11 @@ public:
|
|||
|
||||
static min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));}
|
||||
|
||||
template <class U> friend bool operator==(min_pointer<U>, min_pointer<U>);
|
||||
friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
|
||||
friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
|
||||
template <class U> friend class min_pointer;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
bool
|
||||
operator==(min_pointer<T> x, min_pointer<T> y)
|
||||
{
|
||||
return x.ptr_ == y.ptr_;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
bool
|
||||
operator!=(min_pointer<T> x, min_pointer<T> y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
bool
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -31,4 +32,13 @@ int main()
|
|||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == other_allocator<bool>(5));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
|
||||
std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
|
||||
l2 = l;
|
||||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == min_allocator<bool>());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,15 +14,30 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
std::vector<int> d;
|
||||
{
|
||||
std::vector<bool> d;
|
||||
d.assign({true, false, false, true});
|
||||
assert(d.size() == 4);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> d;
|
||||
d.assign({true, false, false, true});
|
||||
assert(d.size() == 4);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -60,5 +61,21 @@ int main()
|
|||
assert(l.empty());
|
||||
assert(l2.get_allocator() == lo.get_allocator());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
|
||||
std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
|
||||
for (int i = 1; i <= 3; ++i)
|
||||
{
|
||||
l.push_back(i);
|
||||
lo.push_back(i);
|
||||
}
|
||||
std::vector<bool, min_allocator<bool> > l2(min_allocator<bool>{});
|
||||
l2 = std::move(l);
|
||||
assert(l2 == lo);
|
||||
assert(l.empty());
|
||||
assert(l2.get_allocator() == lo.get_allocator());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -27,4 +29,16 @@ int main()
|
|||
v.push_back(0);
|
||||
assert(v.capacity() >= 101);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v;
|
||||
assert(v.capacity() == 0);
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
assert(v.capacity() >= 100);
|
||||
v.push_back(0);
|
||||
assert(v.capacity() >= 101);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <cassert>
|
||||
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -43,4 +44,10 @@ int main()
|
|||
test0<std::vector<bool> >();
|
||||
test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
test0<std::vector<bool, min_allocator<bool>> >();
|
||||
test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C, class Iterator>
|
||||
void
|
||||
|
@ -37,4 +38,11 @@ int main()
|
|||
test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
|
||||
test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
|
||||
test<std::vector<bool> >(a, an);
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
|
||||
test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
|
||||
test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
|
||||
test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
|
||||
test<std::vector<bool, min_allocator<bool>> >(a, an);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C, class Iterator>
|
||||
void
|
||||
|
@ -33,10 +34,22 @@ int main()
|
|||
{
|
||||
bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
|
||||
bool* an = a + sizeof(a)/sizeof(a[0]);
|
||||
{
|
||||
std::allocator<bool> alloc;
|
||||
test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool> >(a, an, alloc);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
min_allocator<bool> alloc;
|
||||
test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
|
||||
test<std::vector<bool, min_allocator<bool>> >(a, an, alloc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(typename C::size_type n)
|
||||
|
@ -30,4 +32,7 @@ test(typename C::size_type n)
|
|||
int main()
|
||||
{
|
||||
test<std::vector<bool> >(50);
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<bool, min_allocator<bool>> >(50);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(typename C::size_type n, const typename C::value_type& x)
|
||||
|
@ -29,4 +31,7 @@ test(typename C::size_type n, const typename C::value_type& x)
|
|||
int main()
|
||||
{
|
||||
test<std::vector<bool> >(50, 3);
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<bool, min_allocator<bool>> >(50, 3);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
test(typename C::size_type n, const typename C::value_type& x,
|
||||
|
@ -31,4 +33,7 @@ test(typename C::size_type n, const typename C::value_type& x,
|
|||
int main()
|
||||
{
|
||||
test<std::vector<bool> >(50, 3, std::allocator<bool>());
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<bool, min_allocator<bool>> >(50, 3, min_allocator<bool>());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -48,4 +49,17 @@ int main()
|
|||
assert(v2.get_allocator() == other_allocator<bool>(-2));
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
|
||||
bool* an = a + sizeof(a)/sizeof(a[0]);
|
||||
test(std::vector<bool, min_allocator<bool>>(a, an));
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>());
|
||||
std::vector<bool, min_allocator<bool> > v2 = v;
|
||||
assert(v2 == v);
|
||||
assert(v2.get_allocator() == v.get_allocator());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -45,4 +46,17 @@ int main()
|
|||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == other_allocator<bool>(3));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
|
||||
int* an = a + sizeof(a)/sizeof(a[0]);
|
||||
test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>());
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
|
||||
std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
|
||||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == min_allocator<bool>());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,9 +15,12 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
bool a1[] = {1, 0, 1};
|
||||
{
|
||||
std::vector<bool> l1(a1, a1+3);
|
||||
std::vector<bool>::const_iterator i = l1.begin();
|
||||
++i;
|
||||
|
@ -36,4 +39,27 @@ int main()
|
|||
assert(j == l1.end());
|
||||
assert(l1.size() == 0);
|
||||
assert(distance(l1.begin(), l1.end()) == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
|
||||
std::vector<bool, min_allocator<bool>>::const_iterator i = l1.begin();
|
||||
++i;
|
||||
std::vector<bool, min_allocator<bool>>::iterator j = l1.erase(i);
|
||||
assert(l1.size() == 2);
|
||||
assert(distance(l1.begin(), l1.end()) == 2);
|
||||
assert(*j == true);
|
||||
assert(*l1.begin() == 1);
|
||||
assert(*next(l1.begin()) == true);
|
||||
j = l1.erase(j);
|
||||
assert(j == l1.end());
|
||||
assert(l1.size() == 1);
|
||||
assert(distance(l1.begin(), l1.end()) == 1);
|
||||
assert(*l1.begin() == true);
|
||||
j = l1.erase(l1.begin());
|
||||
assert(j == l1.end());
|
||||
assert(l1.size() == 0);
|
||||
assert(distance(l1.begin(), l1.end()) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
bool a1[] = {1, 0, 1};
|
||||
|
@ -48,4 +50,36 @@ int main()
|
|||
assert(distance(l1.cbegin(), l1.cend()) == 0);
|
||||
assert(i == l1.begin());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
|
||||
assert(l1.size() == 3);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 3);
|
||||
assert(i == l1.begin());
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
|
||||
assert(l1.size() == 2);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 2);
|
||||
assert(i == l1.begin());
|
||||
assert((l1 == std::vector<bool, min_allocator<bool>>(a1+1, a1+3)));
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
|
||||
assert(l1.size() == 1);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 1);
|
||||
assert(i == l1.begin());
|
||||
assert((l1 == std::vector<bool, min_allocator<bool>>(a1+2, a1+3)));
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
|
||||
assert(l1.size() == 0);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 0);
|
||||
assert(i == l1.begin());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,14 +14,28 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
std::vector<int> d = {true, false, false, true};
|
||||
{
|
||||
std::vector<bool> d = {true, false, false, true};
|
||||
assert(d.size() == 4);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> d = {true, false, false, true};
|
||||
assert(d.size() == 4);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
|
|
@ -15,16 +15,30 @@
|
|||
#include <cassert>
|
||||
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
std::vector<int, test_allocator<int>> d({true, false, false, true}, test_allocator<int>(3));
|
||||
assert(d.get_allocator() == test_allocator<int>(3));
|
||||
{
|
||||
std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
|
||||
assert(d.get_allocator() == test_allocator<bool>(3));
|
||||
assert(d.size() == 4);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>());
|
||||
assert(d.get_allocator() == min_allocator<bool>());
|
||||
assert(d.size() == 4);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::vector<bool> d(10, true);
|
||||
std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
|
||||
assert(d.size() == 14);
|
||||
|
@ -35,5 +38,28 @@ int main()
|
|||
assert(d[11] == true);
|
||||
assert(d[12] == true);
|
||||
assert(d[13] == true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> d(10, true);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
|
||||
assert(d.size() == 14);
|
||||
assert(i == d.begin() + 2);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == true);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
assert(d[4] == true);
|
||||
assert(d[5] == false);
|
||||
assert(d[6] == true);
|
||||
assert(d[7] == true);
|
||||
assert(d[8] == true);
|
||||
assert(d[9] == true);
|
||||
assert(d[10] == true);
|
||||
assert(d[11] == true);
|
||||
assert(d[12] == true);
|
||||
assert(d[13] == true);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "test_iterators.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -51,4 +52,38 @@ int main()
|
|||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
bool a[] = {1, 0, 0, 1, 1};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
|
||||
input_iterator<const bool*>(a+N));
|
||||
assert(v.size() == 100 + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
bool a[] = {1, 0, 0, 1, 1};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
|
||||
forward_iterator<const bool*>(a+N));
|
||||
assert(v.size() == 100 + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -30,4 +32,19 @@ int main()
|
|||
for (++j; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
|
||||
assert(v.size() == 105);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (; j < 15; ++j)
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -29,4 +31,18 @@ int main()
|
|||
for (++j; j < 101; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1);
|
||||
assert(v.size() == 101);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 101; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -56,4 +58,40 @@ int main()
|
|||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef bool T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::iterator i = c.begin();
|
||||
C::iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef bool T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.begin();
|
||||
C::const_iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef bool T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::const_iterator i = c.cbegin();
|
||||
C::const_iterator j = c.cend();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
assert(i == c.end());
|
||||
}
|
||||
{
|
||||
typedef bool T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -44,5 +45,20 @@ int main()
|
|||
assert(l.empty());
|
||||
assert(l2.get_allocator() == lo.get_allocator());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
|
||||
std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
|
||||
for (int i = 1; i <= 3; ++i)
|
||||
{
|
||||
l.push_back(i);
|
||||
lo.push_back(i);
|
||||
}
|
||||
std::vector<bool, min_allocator<bool> > l2 = std::move(l);
|
||||
assert(l2 == lo);
|
||||
assert(l.empty());
|
||||
assert(l2.get_allocator() == lo.get_allocator());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -57,5 +58,20 @@ int main()
|
|||
assert(!l.empty());
|
||||
assert(l2.get_allocator() == other_allocator<bool>(4));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
|
||||
std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
|
||||
for (int i = 1; i <= 3; ++i)
|
||||
{
|
||||
l.push_back(i);
|
||||
lo.push_back(i);
|
||||
}
|
||||
std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
|
||||
assert(l2 == lo);
|
||||
assert(l.empty());
|
||||
assert(l2.get_allocator() == min_allocator<bool>());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::vector<bool> d;
|
||||
d = {true, false, false, true};
|
||||
assert(d.size() == 4);
|
||||
|
@ -24,5 +27,17 @@ int main()
|
|||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> d;
|
||||
d = {true, false, false, true};
|
||||
assert(d.size() == 4);
|
||||
assert(d[0] == true);
|
||||
assert(d[1] == false);
|
||||
assert(d[2] == false);
|
||||
assert(d[3] == true);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
bool a[] = {0, 1, 1, 0, 1, 0, 0};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<int> c;
|
||||
std::vector<bool> c;
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
c.push_back(a[i]);
|
||||
|
@ -29,4 +31,18 @@ int main()
|
|||
assert(c[j] == a[j]);
|
||||
}
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
bool a[] = {0, 1, 1, 0, 1, 0, 0};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<bool, min_allocator<bool>> c;
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
c.push_back(a[i]);
|
||||
assert(c.size() == i+1);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == a[j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -32,4 +34,21 @@ int main()
|
|||
assert(v.size() == 100);
|
||||
assert(v.capacity() >= 150);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v;
|
||||
v.reserve(10);
|
||||
assert(v.capacity() >= 10);
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
assert(v.capacity() >= 100);
|
||||
v.reserve(50);
|
||||
assert(v.size() == 100);
|
||||
assert(v.capacity() >= 100);
|
||||
v.reserve(150);
|
||||
assert(v.size() == 100);
|
||||
assert(v.capacity() >= 150);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -26,4 +28,15 @@ int main()
|
|||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
v.resize(50);
|
||||
assert(v.size() == 50);
|
||||
assert(v.capacity() >= 100);
|
||||
v.resize(200);
|
||||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -31,4 +33,20 @@ int main()
|
|||
for (unsigned i = 50; i < 200; ++i)
|
||||
assert(v[i] == 1);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
v.resize(50, 1);
|
||||
assert(v.size() == 50);
|
||||
assert(v.capacity() >= 100);
|
||||
assert((v == std::vector<bool, min_allocator<bool>>(50)));
|
||||
v.resize(200, 1);
|
||||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
for (unsigned i = 0; i < 50; ++i)
|
||||
assert(v[i] == 0);
|
||||
for (unsigned i = 50; i < 200; ++i)
|
||||
assert(v[i] == 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -24,4 +26,13 @@ int main()
|
|||
assert(v.capacity() >= 101);
|
||||
assert(v.size() >= 101);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
v.push_back(1);
|
||||
v.shrink_to_fit();
|
||||
assert(v.capacity() >= 101);
|
||||
assert(v.size() >= 101);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -61,4 +62,37 @@ int main()
|
|||
assert(v[0] == false);
|
||||
assert(v[1] == true);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v1(100);
|
||||
std::vector<bool, min_allocator<bool>> v2(200);
|
||||
v1.swap(v2);
|
||||
assert(v1.size() == 200);
|
||||
assert(v1.capacity() >= 200);
|
||||
assert(v2.size() == 100);
|
||||
assert(v2.capacity() >= 100);
|
||||
}
|
||||
{
|
||||
typedef min_allocator<bool> A;
|
||||
std::vector<bool, A> v1(100, true, A());
|
||||
std::vector<bool, A> v2(200, false, A());
|
||||
swap(v1, v2);
|
||||
assert(v1.size() == 200);
|
||||
assert(v1.capacity() >= 200);
|
||||
assert(v2.size() == 100);
|
||||
assert(v2.capacity() >= 100);
|
||||
assert(v1.get_allocator() == A());
|
||||
assert(v2.get_allocator() == A());
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(2);
|
||||
std::vector<bool, min_allocator<bool>>::reference r1 = v[0];
|
||||
std::vector<bool, min_allocator<bool>>::reference r2 = v[1];
|
||||
r1 = true;
|
||||
using std::swap;
|
||||
swap(r1, r2);
|
||||
assert(v[0] == false);
|
||||
assert(v[1] == true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../Copyable.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class Allocator>
|
||||
void
|
||||
|
@ -43,8 +44,8 @@ test()
|
|||
static_assert((std::is_same<typename C::value_type, bool>::value), "");
|
||||
static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
|
||||
static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
|
||||
static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
|
||||
static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
|
||||
static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
|
||||
static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
|
||||
static_assert((std::is_same<
|
||||
typename std::iterator_traits<typename C::iterator>::iterator_category,
|
||||
std::random_access_iterator_tag>::value), "");
|
||||
|
@ -65,4 +66,7 @@ int main()
|
|||
test<std::allocator<bool> >();
|
||||
static_assert((std::is_same<std::vector<bool>::allocator_type,
|
||||
std::allocator<bool> >::value), "");
|
||||
#if __cplusplus >= 201103L
|
||||
test<min_allocator<bool> >();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -22,8 +22,11 @@
|
|||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::vector<bool> T;
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
|
||||
|
@ -32,4 +35,17 @@ int main()
|
|||
T vb(std::begin(ba), std::end(ba));
|
||||
H h;
|
||||
assert(h(vb) != 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::vector<bool, min_allocator<bool>> T;
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
|
||||
H>::value), "");
|
||||
bool ba[] = {true, false, true, true, false};
|
||||
T vb(std::begin(ba), std::end(ba));
|
||||
H h;
|
||||
assert(h(vb) != 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -16,5 +16,7 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
std::vector<const int> v = {1, 2, 3};
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
|
@ -30,6 +33,18 @@ int main()
|
|||
c.clear();
|
||||
assert(c.back() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
assert(c.back() == 0);
|
||||
c.clear();
|
||||
assert(c.back() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,13 +21,26 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
const C c;
|
||||
assert(c.back() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
assert(c.back() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,13 +21,26 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
const C c;
|
||||
assert(c.front() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
assert(c.front() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,14 +21,28 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
const C c(1);
|
||||
assert(c[0] == 0);
|
||||
assert(c[1] == 0);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const C c(1);
|
||||
assert(c[0] == 0);
|
||||
assert(c[1] == 0);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
|
@ -30,6 +33,18 @@ int main()
|
|||
c.clear();
|
||||
assert(c.front() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
assert(c.front() == 0);
|
||||
c.clear();
|
||||
assert(c.front() == 0);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
|
@ -30,6 +33,18 @@ int main()
|
|||
c.clear();
|
||||
assert(c[0] == 0);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
assert(c[0] == 0);
|
||||
c.clear();
|
||||
assert(c[0] == 0);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,14 +21,28 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c1;
|
||||
C c2;
|
||||
bool b = c1.begin() != c2.begin();
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c1;
|
||||
C c2;
|
||||
bool b = c1.begin() != c2.begin();
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,14 +21,28 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c1;
|
||||
C c2;
|
||||
bool b = c1.begin() < c2.begin();
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c1;
|
||||
C c2;
|
||||
bool b = c1.begin() < c2.begin();
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,14 +21,28 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c1;
|
||||
C c2;
|
||||
int i = c1.begin() - c2.begin();
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c1;
|
||||
C c2;
|
||||
int i = c1.begin() - c2.begin();
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
|
@ -30,6 +33,18 @@ int main()
|
|||
assert(i[0] == 0);
|
||||
assert(i[1] == 0);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
C::iterator i = c.begin();
|
||||
assert(i[0] == 0);
|
||||
assert(i[1] == 0);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
|
@ -32,6 +35,20 @@ int main()
|
|||
i = c.begin();
|
||||
i += 2;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
C::iterator i = c.begin();
|
||||
i += 1;
|
||||
assert(i == c.end());
|
||||
i = c.begin();
|
||||
i += 2;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
|
@ -31,6 +34,19 @@ int main()
|
|||
assert(i == c.begin());
|
||||
--i;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
C::iterator i = c.end();
|
||||
--i;
|
||||
assert(i == c.begin());
|
||||
--i;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
|
@ -31,6 +34,19 @@ int main()
|
|||
assert(i == c.end());
|
||||
++i;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
C::iterator i = c.begin();
|
||||
++i;
|
||||
assert(i == c.end());
|
||||
++i;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -21,14 +21,28 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T> C;
|
||||
C c(1);
|
||||
C::iterator i = c.end();
|
||||
T j = *i;
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c(1);
|
||||
C::iterator i = c.end();
|
||||
T j = *i;
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -20,6 +20,14 @@
|
|||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
struct A
|
||||
{
|
||||
int first;
|
||||
int second;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -69,4 +77,62 @@ int main()
|
|||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::iterator i = c.begin();
|
||||
C::iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.begin();
|
||||
C::const_iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::const_iterator i = c.cbegin();
|
||||
C::const_iterator j = c.cend();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
assert(i == c.end());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
C::iterator i = c.begin();
|
||||
assert(*i == 0);
|
||||
++i;
|
||||
assert(*i == 1);
|
||||
*i = 10;
|
||||
assert(*i == 10);
|
||||
assert(std::distance(c.begin(), c.end()) == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
{
|
||||
typedef A T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c = {A{1, 2}};
|
||||
C::iterator i = c.begin();
|
||||
i->first = 3;
|
||||
C::const_iterator j = i;
|
||||
assert(j->first == 3);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "../../test_allocator.h"
|
||||
#include "../../Copyable.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class T, class Allocator>
|
||||
void
|
||||
|
@ -72,4 +73,12 @@ int main()
|
|||
test<Copyable, test_allocator<Copyable> >();
|
||||
static_assert((std::is_same<std::vector<char>::allocator_type,
|
||||
std::allocator<char> >::value), "");
|
||||
#if __cplusplus >= 201103L
|
||||
static_assert((std::is_same<std::vector<int, min_allocator<int>>::value_type, int>::value), "");
|
||||
static_assert((std::is_same<std::vector<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
|
||||
static_assert((std::is_same<std::vector<int, min_allocator<int>>::reference, int&>::value), "");
|
||||
static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_reference, const int&>::value), "");
|
||||
static_assert((std::is_same<std::vector<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
|
||||
static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -26,4 +28,16 @@ int main()
|
|||
v.push_back(0);
|
||||
assert(v.capacity() > 101);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v;
|
||||
assert(v.capacity() == 0);
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
assert(v.capacity() == 100);
|
||||
v.push_back(0);
|
||||
assert(v.capacity() > 101);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -42,4 +43,21 @@ int main()
|
|||
assert(v.size() == 100);
|
||||
assert(v.capacity() == 150);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v;
|
||||
v.reserve(10);
|
||||
assert(v.capacity() >= 10);
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
assert(v.capacity() == 100);
|
||||
v.reserve(50);
|
||||
assert(v.size() == 100);
|
||||
assert(v.capacity() == 100);
|
||||
v.reserve(150);
|
||||
assert(v.size() == 100);
|
||||
assert(v.capacity() == 150);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -57,4 +58,15 @@ int main()
|
|||
assert(v.capacity() >= 200);
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
|
||||
v.resize(50);
|
||||
assert(v.size() == 50);
|
||||
assert(v.capacity() == 100);
|
||||
v.resize(200);
|
||||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -40,4 +41,29 @@ int main()
|
|||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
v.resize(50, 1);
|
||||
assert(v.size() == 50);
|
||||
assert(v.capacity() == 100);
|
||||
assert((v == std::vector<int, min_allocator<int>>(50)));
|
||||
v.resize(200, 1);
|
||||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
for (unsigned i = 0; i < 50; ++i)
|
||||
assert(v[i] == 0);
|
||||
for (unsigned i = 50; i < 200; ++i)
|
||||
assert(v[i] == 1);
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
v.resize(50, 1);
|
||||
assert(v.size() == 50);
|
||||
assert(v.capacity() == 100);
|
||||
v.resize(200, 1);
|
||||
assert(v.size() == 200);
|
||||
assert(v.capacity() >= 200);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -40,4 +41,13 @@ int main()
|
|||
assert(v.size() == 101);
|
||||
}
|
||||
#endif
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
v.push_back(1);
|
||||
v.shrink_to_fit();
|
||||
assert(v.capacity() == 101);
|
||||
assert(v.size() == 101);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -25,4 +27,15 @@ int main()
|
|||
assert(v2.size() == 100);
|
||||
assert(v2.capacity() == 100);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v1(100);
|
||||
std::vector<int, min_allocator<int>> v2(200);
|
||||
v1.swap(v2);
|
||||
assert(v1.size() == 200);
|
||||
assert(v1.capacity() == 200);
|
||||
assert(v2.size() == 100);
|
||||
assert(v2.capacity() == 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -31,4 +32,13 @@ int main()
|
|||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == other_allocator<int>(5));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
|
||||
std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
|
||||
l2 = l;
|
||||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == min_allocator<int>());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::vector<int> d;
|
||||
d.assign({3, 4, 5, 6});
|
||||
assert(d.size() == 4);
|
||||
|
@ -24,5 +27,17 @@ int main()
|
|||
assert(d[1] == 4);
|
||||
assert(d[2] == 5);
|
||||
assert(d[3] == 6);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<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
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <cassert>
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -61,5 +62,21 @@ int main()
|
|||
assert(l.empty());
|
||||
assert(l2.get_allocator() == lo.get_allocator());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
|
||||
for (int i = 1; i <= 3; ++i)
|
||||
{
|
||||
l.push_back(i);
|
||||
lo.push_back(i);
|
||||
}
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
|
||||
l2 = std::move(l);
|
||||
assert(l2 == lo);
|
||||
assert(l.empty());
|
||||
assert(l2.get_allocator() == lo.get_allocator());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "../../../test_allocator.h"
|
||||
#include "../../../NotConstructible.h"
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -51,4 +52,17 @@ int main()
|
|||
std::vector<int, stack_allocator<int, 10> > v;
|
||||
assert(v.empty());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
test0<std::vector<int, min_allocator<int>> >();
|
||||
test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
|
||||
test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{});
|
||||
test1<std::vector<NotConstructible, min_allocator<NotConstructible> > >
|
||||
(min_allocator<NotConstructible>{});
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int> > v;
|
||||
assert(v.empty());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "test_iterators.h"
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C, class Iterator>
|
||||
void
|
||||
|
@ -43,4 +44,11 @@ int main()
|
|||
test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
|
||||
test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
|
||||
test<std::vector<int, stack_allocator<int, 18> > >(a, an);
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
|
||||
test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
|
||||
test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
|
||||
test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
|
||||
test<std::vector<int> >(a, an);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "test_iterators.h"
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C, class Iterator>
|
||||
void
|
||||
|
@ -31,6 +32,7 @@ test(Iterator first, Iterator last, const typename C::allocator_type& a)
|
|||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
|
||||
int* an = a + sizeof(a)/sizeof(a[0]);
|
||||
std::allocator<int> alloc;
|
||||
|
@ -39,4 +41,17 @@ int main()
|
|||
test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
|
||||
test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
|
||||
test<std::vector<int> >(a, an, alloc);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
|
||||
int* an = a + sizeof(a)/sizeof(a[0]);
|
||||
min_allocator<int> alloc;
|
||||
test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
|
||||
test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
|
||||
test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
|
||||
test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
|
||||
test<std::vector<int, min_allocator<int>> >(a, an, alloc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <cassert>
|
||||
|
||||
#include "../../../DefaultOnly.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -35,4 +36,9 @@ int main()
|
|||
test<std::vector<int> >(50);
|
||||
test<std::vector<DefaultOnly> >(500);
|
||||
assert(DefaultOnly::count == 0);
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<int, min_allocator<int>> >(50);
|
||||
test<std::vector<DefaultOnly, min_allocator<DefaultOnly>> >(500);
|
||||
assert(DefaultOnly::count == 0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <cassert>
|
||||
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -31,4 +32,7 @@ int main()
|
|||
{
|
||||
test<std::vector<int> >(50, 3);
|
||||
test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<int, min_allocator<int>> >(50, 3);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -30,4 +31,7 @@ test(typename C::size_type n, const typename C::value_type& x,
|
|||
int main()
|
||||
{
|
||||
test<std::vector<int> >(50, 3, std::allocator<int>());
|
||||
#if __cplusplus >= 201103L
|
||||
test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -47,4 +48,17 @@ int main()
|
|||
assert(v2.get_allocator() == other_allocator<int>(-2));
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
|
||||
int* an = a + sizeof(a)/sizeof(a[0]);
|
||||
test(std::vector<int, min_allocator<int>>(a, an));
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int> > v(3, 2, min_allocator<int>());
|
||||
std::vector<int, min_allocator<int> > v2 = v;
|
||||
assert(v2 == v);
|
||||
assert(v2.get_allocator() == v.get_allocator());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
template <class C>
|
||||
void
|
||||
|
@ -45,4 +46,17 @@ int main()
|
|||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == other_allocator<int>(3));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
|
||||
int* an = a + sizeof(a)/sizeof(a[0]);
|
||||
test(std::vector<int, min_allocator<int>>(a, an), min_allocator<int>());
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
|
||||
std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
|
||||
assert(l2 == l);
|
||||
assert(l2.get_allocator() == min_allocator<int>());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -13,15 +13,28 @@
|
|||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::vector<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::vector<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
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@
|
|||
#include <cassert>
|
||||
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::vector<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);
|
||||
|
@ -26,5 +28,17 @@ int main()
|
|||
assert(d[1] == 4);
|
||||
assert(d[2] == 5);
|
||||
assert(d[3] == 6);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<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
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <cassert>
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -53,5 +54,28 @@ int main()
|
|||
std::vector<int>::iterator j = c2.erase(i);
|
||||
assert(*j == 3);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
|
||||
for (int i = 1; i <= 3; ++i)
|
||||
{
|
||||
l.push_back(i);
|
||||
lo.push_back(i);
|
||||
}
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
|
||||
assert(l2 == lo);
|
||||
assert(l.empty());
|
||||
assert(l2.get_allocator() == lo.get_allocator());
|
||||
}
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
||||
std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
|
||||
std::vector<int, min_allocator<int>> c2 = std::move(c1);
|
||||
std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
|
||||
assert(*j == 3);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <cassert>
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -58,5 +59,20 @@ int main()
|
|||
assert(!l.empty());
|
||||
assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
|
||||
for (int i = 1; i <= 3; ++i)
|
||||
{
|
||||
l.push_back(i);
|
||||
lo.push_back(i);
|
||||
}
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
|
||||
assert(l2 == lo);
|
||||
assert(l.empty());
|
||||
assert(l2.get_allocator() == min_allocator<MoveOnly>());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::vector<int> d;
|
||||
d = {3, 4, 5, 6};
|
||||
assert(d.size() == 4);
|
||||
|
@ -24,5 +27,17 @@ int main()
|
|||
assert(d[1] == 4);
|
||||
assert(d[2] == 5);
|
||||
assert(d[3] == 6);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<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
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -24,4 +26,14 @@ int main()
|
|||
std::vector<int> v(100);
|
||||
assert(v.data() == &v.front());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v;
|
||||
assert(v.data() == 0);
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
assert(v.data() == &v.front());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -24,4 +26,14 @@ int main()
|
|||
const std::vector<int> v(100);
|
||||
assert(v.data() == &v.front());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
const std::vector<int, min_allocator<int>> v;
|
||||
assert(v.data() == 0);
|
||||
}
|
||||
{
|
||||
const std::vector<int, min_allocator<int>> v(100);
|
||||
assert(v.data() == &v.front());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
|
@ -114,5 +115,39 @@ int main()
|
|||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<A, min_allocator<A>> c;
|
||||
std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
|
||||
assert(i == c.begin());
|
||||
assert(c.size() == 1);
|
||||
assert(c.front().geti() == 2);
|
||||
assert(c.front().getd() == 3.5);
|
||||
i = c.emplace(c.cend(), 3, 4.5);
|
||||
assert(i == c.end()-1);
|
||||
assert(c.size() == 2);
|
||||
assert(c.front().geti() == 2);
|
||||
assert(c.front().getd() == 3.5);
|
||||
assert(c.back().geti() == 3);
|
||||
assert(c.back().getd() == 4.5);
|
||||
i = c.emplace(c.cbegin()+1, 4, 6.5);
|
||||
assert(i == c.begin()+1);
|
||||
assert(c.size() == 3);
|
||||
assert(c.front().geti() == 2);
|
||||
assert(c.front().getd() == 3.5);
|
||||
assert(c[1].geti() == 4);
|
||||
assert(c[1].getd() == 6.5);
|
||||
assert(c.back().geti() == 3);
|
||||
assert(c.back().getd() == 4.5);
|
||||
}
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::vector<A, min_allocator<A>> c1;
|
||||
std::vector<A, min_allocator<A>> c2;
|
||||
std::vector<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
|
@ -80,5 +81,20 @@ int main()
|
|||
assert(c.back().geti() == 3);
|
||||
assert(c.back().getd() == 4.5);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<A, min_allocator<A>> c;
|
||||
c.emplace_back(2, 3.5);
|
||||
assert(c.size() == 1);
|
||||
assert(c.front().geti() == 2);
|
||||
assert(c.front().getd() == 3.5);
|
||||
c.emplace_back(3, 4.5);
|
||||
assert(c.size() == 2);
|
||||
assert(c.front().geti() == 2);
|
||||
assert(c.front().getd() == 3.5);
|
||||
assert(c.back().geti() == 3);
|
||||
assert(c.back().getd() == 4.5);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
@ -30,5 +33,21 @@ int main()
|
|||
v.emplace(v.begin(), v.back());
|
||||
assert(v[0] == 3);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v;
|
||||
v.reserve(3);
|
||||
v = { 1, 2, 3 };
|
||||
v.emplace(v.begin(), v.back());
|
||||
assert(v[0] == 3);
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v;
|
||||
v.reserve(4);
|
||||
v = { 1, 2, 3 };
|
||||
v.emplace(v.begin(), v.back());
|
||||
assert(v[0] == 3);
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
|
|
@ -14,8 +14,11 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int> l1(a1, a1+3);
|
||||
std::vector<int>::const_iterator i = l1.begin();
|
||||
|
@ -35,4 +38,28 @@ int main()
|
|||
assert(j == l1.end());
|
||||
assert(l1.size() == 0);
|
||||
assert(distance(l1.begin(), l1.end()) == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::const_iterator i = l1.begin();
|
||||
++i;
|
||||
std::vector<int, min_allocator<int>>::iterator j = l1.erase(i);
|
||||
assert(l1.size() == 2);
|
||||
assert(distance(l1.begin(), l1.end()) == 2);
|
||||
assert(*j == 3);
|
||||
assert(*l1.begin() == 1);
|
||||
assert(*next(l1.begin()) == 3);
|
||||
j = l1.erase(j);
|
||||
assert(j == l1.end());
|
||||
assert(l1.size() == 1);
|
||||
assert(distance(l1.begin(), l1.end()) == 1);
|
||||
assert(*l1.begin() == 1);
|
||||
j = l1.erase(l1.begin());
|
||||
assert(j == l1.end());
|
||||
assert(l1.size() == 0);
|
||||
assert(distance(l1.begin(), l1.end()) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -20,13 +20,26 @@
|
|||
#include <cstdlib>
|
||||
#include <exception>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int> l1(a1, a1+3);
|
||||
std::vector<int>::const_iterator i = l1.end();
|
||||
l1.erase(i);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::const_iterator i = l1.end();
|
||||
l1.erase(i);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -20,14 +20,28 @@
|
|||
#include <cstdlib>
|
||||
#include <exception>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int> l1(a1, a1+3);
|
||||
std::vector<int> l2(a1, a1+3);
|
||||
std::vector<int>::const_iterator i = l2.begin();
|
||||
l1.erase(i);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::const_iterator i = l2.begin();
|
||||
l1.erase(i);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
|
@ -54,4 +56,43 @@ int main()
|
|||
assert(outer[0].size() == 1);
|
||||
assert(outer[1].size() == 1);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
|
||||
assert(l1.size() == 3);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 3);
|
||||
assert(i == l1.begin());
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
|
||||
assert(l1.size() == 2);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 2);
|
||||
assert(i == l1.begin());
|
||||
assert((l1 == std::vector<int, min_allocator<int>>(a1+1, a1+3)));
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
|
||||
assert(l1.size() == 1);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 1);
|
||||
assert(i == l1.begin());
|
||||
assert((l1 == std::vector<int, min_allocator<int>>(a1+2, a1+3)));
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
|
||||
assert(l1.size() == 0);
|
||||
assert(distance(l1.cbegin(), l1.cend()) == 0);
|
||||
assert(i == l1.begin());
|
||||
}
|
||||
{
|
||||
std::vector<std::vector<int, min_allocator<int>>, min_allocator<std::vector<int, min_allocator<int>>>> outer(2, std::vector<int, min_allocator<int>>(1));
|
||||
outer.erase(outer.begin(), outer.begin());
|
||||
assert(outer.size() == 2);
|
||||
assert(outer[0].size() == 1);
|
||||
assert(outer[1].size() == 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -20,13 +20,26 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int> l1(a1, a1+3);
|
||||
std::vector<int> l2(a1, a1+3);
|
||||
std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -20,13 +20,26 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int> l1(a1, a1+3);
|
||||
std::vector<int> l2(a1, a1+3);
|
||||
std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -20,13 +20,26 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int> l1(a1, a1+3);
|
||||
std::vector<int> l2(a1, a1+3);
|
||||
std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -20,12 +20,24 @@
|
|||
#include <exception>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int> l1(a1, a1+3);
|
||||
std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 2, 3};
|
||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::vector<int> d(10, 1);
|
||||
std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
|
||||
assert(d.size() == 14);
|
||||
|
@ -35,5 +38,28 @@ int main()
|
|||
assert(d[11] == 1);
|
||||
assert(d[12] == 1);
|
||||
assert(d[13] == 1);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> d(10, 1);
|
||||
std::vector<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
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "test_iterators.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -98,4 +99,49 @@ int main()
|
|||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
int a[] = {1, 2, 3, 4, 5};
|
||||
const int N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
|
||||
input_iterator<const int*>(a+N));
|
||||
assert(v.size() == 100 + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
int a[] = {1, 2, 3, 4, 5};
|
||||
const int N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
|
||||
forward_iterator<const int*>(a+N));
|
||||
assert(v.size() == 100 + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
std::vector<int, min_allocator<int>> v2(100);
|
||||
int a[] = {1, 2, 3, 4, 5};
|
||||
const int N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<int, min_allocator<int>>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
|
||||
input_iterator<const int*>(a+N));
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -55,5 +56,27 @@ int main()
|
|||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
|
||||
assert(v.size() == 101);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == MoveOnly());
|
||||
assert(v[j] == MoveOnly(3));
|
||||
for (++j; j < 101; ++j)
|
||||
assert(v[j] == MoveOnly());
|
||||
}
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v1(3);
|
||||
std::vector<int, min_allocator<int>> v2(3);
|
||||
v1.insert(v2.begin(), 4);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -55,4 +56,40 @@ int main()
|
|||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
|
||||
assert(v.size() == 105);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (; j < 15; ++j)
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
|
||||
assert(v.size() == 105);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (; j < 15; ++j)
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::vector<int, min_allocator<int>> c1(100);
|
||||
std::vector<int, min_allocator<int>> c2;
|
||||
std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -54,4 +55,27 @@ int main()
|
|||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v(100);
|
||||
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 1);
|
||||
assert(v.size() == 101);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
assert(v[j] == 1);
|
||||
for (++j; j < 101; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
{
|
||||
std::vector<int, min_allocator<int>> v1(3);
|
||||
std::vector<int, min_allocator<int>> v2(3);
|
||||
int i = 4;
|
||||
v1.insert(v2.begin(), i);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
#include <cstdlib>
|
||||
|
@ -38,4 +39,17 @@ int main()
|
|||
assert(false);
|
||||
#endif
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> c;
|
||||
c.push_back(1);
|
||||
assert(c.size() == 1);
|
||||
c.pop_back();
|
||||
assert(c.size() == 0);
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
c.pop_back();
|
||||
assert(false);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -63,4 +64,29 @@ int main()
|
|||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == j);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<int, min_allocator<int>> c;
|
||||
c.push_back(0);
|
||||
assert(c.size() == 1);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == j);
|
||||
c.push_back(1);
|
||||
assert(c.size() == 2);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == j);
|
||||
c.push_back(2);
|
||||
assert(c.size() == 3);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == j);
|
||||
c.push_back(3);
|
||||
assert(c.size() == 4);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == j);
|
||||
c.push_back(4);
|
||||
assert(c.size() == 5);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == j);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <cassert>
|
||||
#include "../../../MoveOnly.h"
|
||||
#include "../../../stack_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -65,5 +66,30 @@ int main()
|
|||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == MoveOnly(j));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<MoveOnly, min_allocator<MoveOnly>> c;
|
||||
c.push_back(MoveOnly(0));
|
||||
assert(c.size() == 1);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == MoveOnly(j));
|
||||
c.push_back(MoveOnly(1));
|
||||
assert(c.size() == 2);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == MoveOnly(j));
|
||||
c.push_back(MoveOnly(2));
|
||||
assert(c.size() == 3);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == MoveOnly(j));
|
||||
c.push_back(MoveOnly(3));
|
||||
assert(c.size() == 4);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == MoveOnly(j));
|
||||
c.push_back(MoveOnly(4));
|
||||
assert(c.size() == 5);
|
||||
for (int j = 0; j < c.size(); ++j)
|
||||
assert(c[j] == MoveOnly(j));
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#if _LIBCPP_DEBUG2 >= 1
|
||||
|
@ -35,5 +37,20 @@ int main()
|
|||
c1.erase(i1);
|
||||
assert(false);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
||||
std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
||||
std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
|
||||
std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
|
||||
swap(c1, c2);
|
||||
c1.erase(i2);
|
||||
c2.erase(i1);
|
||||
c1.erase(i1);
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "../../../test_allocator.h"
|
||||
#include "../../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -85,4 +86,61 @@ int main()
|
|||
assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
|
||||
assert(c2.get_allocator() == A(1));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
||||
std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
||||
swap(c1, c2);
|
||||
assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
|
||||
assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
|
||||
}
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
std::vector<int, min_allocator<int>> c1(a1, a1);
|
||||
std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
||||
swap(c1, c2);
|
||||
assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
|
||||
assert(c2.empty());
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
}
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
||||
std::vector<int, min_allocator<int>> c2(a2, a2);
|
||||
swap(c1, c2);
|
||||
assert(c1.empty());
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
|
||||
}
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
std::vector<int, min_allocator<int>> c1(a1, a1);
|
||||
std::vector<int, min_allocator<int>> c2(a2, a2);
|
||||
swap(c1, c2);
|
||||
assert(c1.empty());
|
||||
assert(distance(c1.begin(), c1.end()) == 0);
|
||||
assert(c2.empty());
|
||||
assert(distance(c2.begin(), c2.end()) == 0);
|
||||
}
|
||||
#ifndef _LIBCPP_DEBUG_LEVEL
|
||||
// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
|
||||
{
|
||||
int a1[] = {1, 3, 7, 9, 10};
|
||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||
typedef min_allocator<int> A;
|
||||
std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
|
||||
std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
|
||||
swap(c1, c2);
|
||||
assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
|
||||
assert(c1.get_allocator() == A());
|
||||
assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
|
||||
assert(c2.get_allocator() == A());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue