Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in vector.

This patch cleans up all usages of the following feature test macros inside
<vector> and its tests:

* _LIBCPP_HAS_NO_RVALUE_REFERENCES
* _LIBCPP_HAS_NO_VARIADICS
* _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

Where needed the above guards were replaced with _LIBCPP_CXX03_LANG.

llvm-svn: 300410
This commit is contained in:
Eric Fiselier 2017-04-16 02:40:45 +00:00
parent 539b1ec9d8
commit 843d910103
20 changed files with 121 additions and 164 deletions

View File

@ -527,12 +527,7 @@ public:
is_constructible<
value_type,
typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il);
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_INLINE_VISIBILITY
~vector()
@ -545,7 +540,14 @@ public:
vector(const vector& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(const vector& __x);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il);
_LIBCPP_INLINE_VISIBILITY
vector(initializer_list<value_type> __il, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
@ -553,17 +555,18 @@ public:
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
_LIBCPP_INLINE_VISIBILITY
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif // !_LIBCPP_CXX03_LANG
template <class _InputIterator>
typename enable_if
@ -588,11 +591,12 @@ public:
assign(_ForwardIterator __first, _ForwardIterator __last);
void assign(size_type __n, const_reference __u);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
@ -676,9 +680,10 @@ public:
{return _VSTD::__to_raw_pointer(this->__begin_);}
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER > 14
@ -686,19 +691,19 @@ public:
#else
void emplace_back(_Args&&... __args);
#endif
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void pop_back();
iterator insert(const_iterator __position, const_reference __x);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
iterator insert(const_iterator __position, value_type&& __x);
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
iterator emplace(const_iterator __position, _Args&&... __args);
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !_LIBCPP_CXX03_LANG
iterator insert(const_iterator __position, size_type __n, const_reference __x);
template <class _InputIterator>
typename enable_if
@ -721,11 +726,12 @@ public:
iterator
>::type
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif
_LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
iterator erase(const_iterator __first, const_iterator __last);
@ -798,18 +804,16 @@ private:
__base::__destruct_at_end(__new_last);
__annotate_shrink(__old_size);
}
template <class _Up>
void
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__push_back_slow_path(_Up&& __x);
#else
__push_back_slow_path(_Up& __x);
#endif
#if !defined(_LIBCPP_HAS_NO_VARIADICS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#ifndef _LIBCPP_CXX03_LANG
template <class _Up> void __push_back_slow_path(_Up&& __x);
template <class... _Args>
void
__emplace_back_slow_path(_Args&&... __args);
void __emplace_back_slow_path(_Args&&... __args);
#else
template <class _Up> void __push_back_slow_path(_Up& __x);
#endif
// The following functions are no-ops outside of AddressSanitizer mode.
// We call annotatations only for the default Allocator because other allocators
// may not meet the AddressSanitizer alignment constraints.
@ -1219,7 +1223,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
}
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@ -1266,8 +1270,6 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
}
}
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
@ -1297,8 +1299,6 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
}
}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>&
@ -1340,7 +1340,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
#endif
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@ -1562,7 +1562,7 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
template <class _Tp, class _Allocator>
template <class _Up>
void
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
#else
vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
@ -1593,7 +1593,7 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
__push_back_slow_path(__x);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@ -1613,8 +1613,6 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
__push_back_slow_path(_VSTD::move(__x));
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _Allocator>
template <class... _Args>
void
@ -1654,8 +1652,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
#endif
}
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline
@ -1760,7 +1757,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
return __make_iter(__p);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
@ -1799,8 +1796,6 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
return __make_iter(__p);
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _Allocator>
template <class... _Args>
typename vector<_Tp, _Allocator>::iterator
@ -1840,8 +1835,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
return __make_iter(__p);
}
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
@ -2038,7 +2032,7 @@ vector<_Tp, _Allocator>::swap(vector& __x)
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__end_, __x.__end_);
_VSTD::swap(this->__end_cap(), __x.__end_cap());
__swap_allocator(this->__alloc(), __x.__alloc(),
__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->swap(this, &__x);
@ -2233,12 +2227,11 @@ public:
vector(const vector& __v);
vector(const vector& __v, const allocator_type& __a);
vector& operator=(const vector& __v);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_CXX03_LANG
vector(initializer_list<value_type> __il);
vector(initializer_list<value_type> __il, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
@ -2250,12 +2243,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
_LIBCPP_INLINE_VISIBILITY
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif // !_LIBCPP_CXX03_LANG
template <class _InputIterator>
typename enable_if
@ -2274,11 +2267,12 @@ public:
assign(_ForwardIterator __first, _ForwardIterator __last);
void assign(size_type __n, const value_type& __x);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif
_LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(this->__alloc());}
@ -2387,11 +2381,12 @@ public:
iterator
>::type
insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __position, initializer_list<value_type> __il)
{return insert(__position, __il.begin(), __il.end());}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif
_LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
iterator erase(const_iterator __first, const_iterator __last);
@ -2751,7 +2746,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
}
}
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#ifndef _LIBCPP_CXX03_LANG
template <class _Allocator>
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
@ -2781,7 +2776,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
}
}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif // _LIBCPP_CXX03_LANG
template <class _Allocator>
vector<bool, _Allocator>::~vector()
@ -2838,7 +2833,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
return *this;
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_CXX03_LANG
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@ -2913,7 +2908,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
__c.__cap() = __c.__size_ = 0;
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // !_LIBCPP_CXX03_LANG
template <class _Allocator>
void
@ -3203,7 +3198,7 @@ vector<bool, _Allocator>::swap(vector& __x)
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__size_, __x.__size_);
_VSTD::swap(this->__cap(), __x.__cap());
__swap_allocator(this->__alloc(), __x.__alloc(),
__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// void assign(initializer_list<value_type> il);
@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::vector<bool> d;
d.assign({true, false, false, true});
@ -28,7 +29,6 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#if TEST_STD_VER >= 11
{
std::vector<bool, min_allocator<bool>> d;
d.assign({true, false, false, true});
@ -38,6 +38,4 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector& operator=(vector&& c);
@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
@ -61,7 +62,6 @@ int main()
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
}
#if TEST_STD_VER >= 11
{
std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
@ -76,6 +76,4 @@ int main()
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(initializer_list<value_type> il);
@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::vector<bool> d = {true, false, false, true};
assert(d.size() == 4);
@ -27,7 +28,6 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#if TEST_STD_VER >= 11
{
std::vector<bool, min_allocator<bool>> d = {true, false, false, true};
assert(d.size() == 4);
@ -36,6 +36,4 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
@ -19,7 +21,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
assert(d.get_allocator() == test_allocator<bool>(3));
@ -29,7 +30,6 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#if TEST_STD_VER >= 11
{
std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>());
assert(d.get_allocator() == min_allocator<bool>());
@ -39,6 +39,4 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// iterator insert(const_iterator p, initializer_list<value_type> il);
@ -18,7 +20,6 @@
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});
@ -39,7 +40,6 @@ int main()
assert(d[12] == true);
assert(d[13] == true);
}
#if TEST_STD_VER >= 11
{
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});
@ -60,6 +60,4 @@ int main()
assert(d[12] == true);
assert(d[13] == true);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(vector&& c);
@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
@ -45,7 +46,6 @@ int main()
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
}
#if TEST_STD_VER >= 11
{
std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
@ -59,6 +59,4 @@ int main()
assert(l.empty());
assert(l2.get_allocator() == lo.get_allocator());
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(vector&& c, const allocator_type& a);
@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
@ -58,7 +59,6 @@ int main()
assert(!l.empty());
assert(l2.get_allocator() == other_allocator<bool>(4));
}
#if TEST_STD_VER >= 11
{
std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
@ -72,6 +72,4 @@ int main()
assert(l.empty());
assert(l2.get_allocator() == min_allocator<bool>());
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector& operator=(initializer_list<value_type> il);
@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::vector<bool> d;
d = {true, false, false, true};
@ -28,7 +29,6 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#if TEST_STD_VER >= 11
{
std::vector<bool, min_allocator<bool>> d;
d = {true, false, false, true};
@ -38,6 +38,4 @@ int main()
assert(d[2] == false);
assert(d[3] == true);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -13,6 +13,8 @@
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "test_allocator.h"
#include "MoveOnly.h"
#include "min_allocator.h"
@ -20,31 +22,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<MoveOnly> v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
{
// Add 1 for implementations that dynamically allocate a container proxy.
std::vector<MoveOnly, limited_allocator<MoveOnly, 300 + 1> > v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<int> v(100);
v.resize(50);
@ -68,8 +45,30 @@ int main()
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if TEST_STD_VER >= 11
{
std::vector<MoveOnly> v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
{
// Add 1 for implementations that dynamically allocate a container proxy.
std::vector<MoveOnly, limited_allocator<MoveOnly, 300 + 1> > v(100);
v.resize(50);
assert(v.size() == 50);
assert(v.capacity() == 100);
assert(is_contiguous_container_asan_correct(v));
v.resize(200);
assert(v.size() == 200);
assert(v.capacity() >= 200);
assert(is_contiguous_container_asan_correct(v));
}
{
std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
v.resize(50);

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// void assign(initializer_list<value_type> il);
@ -20,7 +22,6 @@
template <typename Vec>
void test ( Vec &v )
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
v.assign({3, 4, 5, 6});
assert(v.size() == 4);
assert(is_contiguous_container_asan_correct(v));
@ -28,7 +29,6 @@ void test ( Vec &v )
assert(v[1] == 4);
assert(v[2] == 5);
assert(v[3] == 6);
#endif
}
int main()
@ -41,8 +41,6 @@ int main()
test(d1);
test(d2);
}
#if TEST_STD_VER >= 11
{
typedef std::vector<int, min_allocator<int>> V;
V d1;
@ -51,5 +49,4 @@ int main()
test(d1);
test(d2);
}
#endif
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector& operator=(vector&& c);
@ -20,7 +22,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@ -76,7 +77,6 @@ int main()
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
#if TEST_STD_VER >= 11
{
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
@ -96,6 +96,4 @@ int main()
assert(l2.get_allocator() == lo.get_allocator());
assert(is_contiguous_container_asan_correct(l2));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(initializer_list<value_type> il);
@ -18,7 +20,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::vector<int> d = {3, 4, 5, 6};
assert(d.size() == 4);
@ -28,7 +29,6 @@ int main()
assert(d[2] == 5);
assert(d[3] == 6);
}
#if TEST_STD_VER >= 11
{
std::vector<int, min_allocator<int>> d = {3, 4, 5, 6};
assert(d.size() == 4);
@ -38,6 +38,4 @@ int main()
assert(d[2] == 5);
assert(d[3] == 6);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
@ -20,7 +22,6 @@
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));
@ -31,7 +32,6 @@ int main()
assert(d[2] == 5);
assert(d[3] == 6);
}
#if TEST_STD_VER >= 11
{
std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
assert(d.get_allocator() == min_allocator<int>());
@ -42,6 +42,4 @@ int main()
assert(d[2] == 5);
assert(d[3] == 6);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(vector&& c);
@ -20,7 +22,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@ -68,7 +69,6 @@ int main()
assert(*j == 3);
assert(is_contiguous_container_asan_correct(c2));
}
#if TEST_STD_VER >= 11
{
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
@ -98,6 +98,4 @@ int main()
assert(*j == 3);
assert(is_contiguous_container_asan_correct(c2));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector(vector&& c, const allocator_type& a);
@ -20,7 +22,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@ -75,7 +76,6 @@ int main()
assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
assert(is_contiguous_container_asan_correct(l2));
}
#if TEST_STD_VER >= 11
{
std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
@ -94,6 +94,4 @@ int main()
assert(l2.get_allocator() == min_allocator<MoveOnly>());
assert(is_contiguous_container_asan_correct(l2));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// vector& operator=(initializer_list<value_type> il);
@ -19,7 +21,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::vector<int> d;
d = {3, 4, 5, 6};
@ -30,7 +31,6 @@ int main()
assert(d[2] == 5);
assert(d[3] == 6);
}
#if TEST_STD_VER >= 11
{
std::vector<int, min_allocator<int>> d;
d = {3, 4, 5, 6};
@ -41,6 +41,4 @@ int main()
assert(d[2] == 5);
assert(d[3] == 6);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
@ -19,7 +21,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::vector<int> v;
v.reserve(3);
@ -38,7 +39,6 @@ int main()
assert(v[0] == 3);
assert(is_contiguous_container_asan_correct(v));
}
#if TEST_STD_VER >= 11
{
std::vector<int, min_allocator<int>> v;
v.reserve(3);
@ -57,6 +57,4 @@ int main()
assert(v[0] == 3);
assert(is_contiguous_container_asan_correct(v));
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// iterator insert(const_iterator p, initializer_list<value_type> il);
@ -19,7 +21,6 @@
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});
@ -41,7 +42,6 @@ int main()
assert(d[12] == 1);
assert(d[13] == 1);
}
#if TEST_STD_VER >= 11
{
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});
@ -63,6 +63,4 @@ int main()
assert(d[12] == 1);
assert(d[13] == 1);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <vector>
// void push_back(value_type&& x);
@ -21,7 +23,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<MoveOnly> c;
c.push_back(MoveOnly(0));
@ -81,7 +82,6 @@ int main()
for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
}
#if TEST_STD_VER >= 11
{
std::vector<MoveOnly, min_allocator<MoveOnly>> c;
c.push_back(MoveOnly(0));
@ -110,6 +110,4 @@ int main()
for (int j = 0; static_cast<std::size_t>(j) < c.size(); ++j)
assert(c[j] == MoveOnly(j));
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}