[libc++] Implement P1004R2 (constexpr std::vector)

Reviewed By: #libc, ldionne

Spies: mgorny, var-const, ormris, philnik, miscco, hiraditya, steven_wu, jkorous, ldionne, christof, libcxx-commits

Differential Revision: https://reviews.llvm.org/D68365
This commit is contained in:
Nikolas Klauser 2022-07-27 14:41:40 +02:00
parent 190f3fbba8
commit 98d3d5b5da
122 changed files with 1818 additions and 736 deletions

View File

@ -38,6 +38,8 @@ What's New in Libc++ 16.0.0?
Implemented Papers
------------------
- P1004R2 (Making ``std::vector`` constexpr)
Improvements and New Features
-----------------------------

View File

@ -107,7 +107,7 @@
"`P0660R10 <https://wg21.link/P0660R10>`__","LWG","Stop Token and Joining Thread, Rev 10","Cologne","",""
"`P0784R7 <https://wg21.link/P0784R7>`__","CWG","More constexpr containers","Cologne","|Complete|","12.0"
"`P0980R1 <https://wg21.link/P0980R1>`__","LWG","Making std::string constexpr","Cologne","|Complete|","15.0"
"`P1004R2 <https://wg21.link/P1004R2>`__","LWG","Making std::vector constexpr","Cologne","",""
"`P1004R2 <https://wg21.link/P1004R2>`__","LWG","Making std::vector constexpr","Cologne","|Complete|","15.0"
"`P1035R7 <https://wg21.link/P1035R7>`__","LWG","Input Range Adaptors","Cologne","",""
"`P1065R2 <https://wg21.link/P1065R2>`__","LWG","Constexpr INVOKE","Cologne","|Complete|","12.0"
"`P1135R6 <https://wg21.link/P1135R6>`__","LWG","The C++20 Synchronization Library","Cologne","|Complete|","11.0"

1 Paper # Group Paper Name Meeting Status First released version
107 `P0660R10 <https://wg21.link/P0660R10>`__ LWG Stop Token and Joining Thread, Rev 10 Cologne
108 `P0784R7 <https://wg21.link/P0784R7>`__ CWG More constexpr containers Cologne |Complete| 12.0
109 `P0980R1 <https://wg21.link/P0980R1>`__ LWG Making std::string constexpr Cologne |Complete| 15.0
110 `P1004R2 <https://wg21.link/P1004R2>`__ LWG Making std::vector constexpr Cologne |Complete| 15.0
111 `P1035R7 <https://wg21.link/P1035R7>`__ LWG Input Range Adaptors Cologne
112 `P1065R2 <https://wg21.link/P1065R2>`__ LWG Constexpr INVOKE Cologne |Complete| 12.0
113 `P1135R6 <https://wg21.link/P1135R6>`__ LWG The C++20 Synchronization Library Cologne |Complete| 11.0

View File

@ -20,6 +20,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
template <class _ForwardIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void

View File

@ -19,6 +19,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator

View File

@ -10,10 +10,13 @@
#ifndef _LIBCPP___BIT_REFERENCE
#define _LIBCPP___BIT_REFERENCE
#include <__algorithm/copy_n.h>
#include <__algorithm/fill_n.h>
#include <__algorithm/min.h>
#include <__bits>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
#include <cstring>
#include <type_traits>
@ -51,15 +54,15 @@ class __bit_reference
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, false>;
public:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference(const __bit_reference&) = default;
_LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
_LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT
{return !static_cast<bool>(*this);}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference& operator=(bool __x) _NOEXCEPT
{
if (__x)
@ -70,7 +73,7 @@ public:
}
#if _LIBCPP_STD_VER > 20
_LIBCPP_HIDE_FROM_ABI const __bit_reference& operator=(bool __x) const noexcept {
_LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept {
if (__x)
*__seg_ |= __mask_;
else
@ -79,15 +82,15 @@ public:
}
#endif
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
{return operator=(static_cast<bool>(__x));}
_LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
_LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
{return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s), __mask_(__m) {}
};
@ -98,7 +101,7 @@ class __bit_reference<_Cp, false>
};
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@ -108,7 +111,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
}
template <class _Cp, class _Dp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
{
@ -118,7 +121,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
{
@ -128,7 +131,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
{
@ -152,14 +155,14 @@ public:
_LIBCPP_INLINE_VISIBILITY
__bit_const_reference(const __bit_const_reference&) = default;
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
: __seg_(__x.__seg_), __mask_(__x.__mask_) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
_LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
{return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
@ -173,12 +176,12 @@ private:
// find
template <class _Cp, bool _IsConst>
__bit_iterator<_Cp, _IsConst>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
static const int __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
// do first partial word
if (__first.__ctz_ != 0)
{
@ -209,7 +212,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst>
__bit_iterator<_Cp, _IsConst>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, _IsConst> _It;
@ -248,7 +251,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
}
template <class _Cp, bool _IsConst, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, _IsConst>
find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
{
@ -334,7 +337,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
// fill_n
template <class _Cp>
void
_LIBCPP_CONSTEXPR_AFTER_CXX17 void
__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@ -352,7 +355,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(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type));
std::fill_n(std::__to_address(__first.__seg_), __nw, 0);
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@ -364,7 +367,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
void
_LIBCPP_CONSTEXPR_AFTER_CXX17 void
__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{
typedef __bit_iterator<_Cp, false> _It;
@ -382,7 +385,8 @@ __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(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
// __storage_type is always an unsigned type, so -1 sets all bits
std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1));
__n -= __nw * __bits_per_word;
// do last partial word
if (__n > 0)
@ -394,7 +398,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
{
@ -410,7 +414,7 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
// fill
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void
fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
{
@ -420,6 +424,7 @@ fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool
// copy
template <class _Cp, bool _IsConst>
_LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
@ -449,9 +454,7 @@ __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(_VSTD::__to_address(__result.__seg_),
_VSTD::__to_address(__first.__seg_),
__nw * sizeof(__storage_type));
std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
__result.__seg_ += __nw;
// do last word
@ -469,6 +472,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
}
template <class _Cp, bool _IsConst>
_LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
@ -476,7 +480,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type;
static const int __bits_per_word = _In::__bits_per_word;
const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first;
if (__n > 0)
{
@ -547,7 +551,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
}
template <class _Cp, bool _IsConst>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@ -559,7 +563,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
// copy_backward
template <class _Cp, bool _IsConst>
__bit_iterator<_Cp, false>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@ -590,9 +594,7 @@ __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(_VSTD::__to_address(__result.__seg_),
_VSTD::__to_address(__last.__seg_),
__nw * sizeof(__storage_type));
std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
__n -= __nw * __bits_per_word;
// do last word
if (__n > 0)
@ -608,7 +610,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
}
template <class _Cp, bool _IsConst>
__bit_iterator<_Cp, false>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
__bit_iterator<_Cp, false> __result)
{
@ -694,7 +696,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
}
template <class _Cp, bool _IsConst>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator<_Cp, false>
copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
{
@ -901,14 +903,19 @@ struct __bit_array
difference_type __size_;
__storage_type __word_[_Np];
_LIBCPP_INLINE_VISIBILITY static difference_type capacity()
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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()
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(difference_type __s) : __size_(__s) {
if (__libcpp_is_constant_evaluated()) {
for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
std::__construct_at(__word_ + __i, 0);
}
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
}
_LIBCPP_INLINE_VISIBILITY iterator end()
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end()
{
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
static_cast<unsigned>(__size_ % __bits_per_word));
@ -916,7 +923,7 @@ struct __bit_array
};
template <class _Cp>
__bit_iterator<_Cp, false>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
{
typedef __bit_iterator<_Cp, false> _I1;
@ -967,14 +974,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
// equal
template <class _Cp, bool _IC1, bool _IC2>
bool
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
__bit_iterator<_Cp, _IC2> __first2)
{
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
static const int __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@ -1049,14 +1056,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
}
template <class _Cp, bool _IC1, bool _IC2>
bool
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
__bit_iterator<_Cp, _IC2> __first2)
{
typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
static const int __bits_per_word = _It::__bits_per_word;
const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1;
if (__n > 0)
{
@ -1092,7 +1099,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
}
template <class _Cp, bool _IC1, bool _IC2>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
{
@ -1126,7 +1133,7 @@ private:
unsigned __ctz_;
public:
_LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT
#if _LIBCPP_STD_VER > 11
: __seg_(nullptr), __ctz_(0)
#endif
@ -1137,7 +1144,7 @@ public:
// When _IsConst=true, this is a converting constructor;
// the copy and move constructors are implicitly generated
// and trivial.
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
: __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
@ -1146,19 +1153,19 @@ public:
// the implicit generation of a defaulted one is deprecated.
// When _IsConst=true, the assignment operators are
// implicitly generated and trivial.
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
__seg_ = __it.__seg_;
__ctz_ = __it.__ctz_;
return *this;
}
_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT {
return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >
::type(__seg_, __storage_type(1) << __ctz_);
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++()
{
if (__ctz_ != __bits_per_word-1)
++__ctz_;
@ -1170,14 +1177,14 @@ public:
return *this;
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int)
{
__bit_iterator __tmp = *this;
++(*this);
return __tmp;
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--()
{
if (__ctz_ != 0)
--__ctz_;
@ -1189,14 +1196,14 @@ public:
return *this;
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int)
{
__bit_iterator __tmp = *this;
--(*this);
return __tmp;
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(difference_type __n)
{
if (__n >= 0)
__seg_ += (__n + __ctz_) / __bits_per_word;
@ -1208,54 +1215,54 @@ public:
return *this;
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(difference_type __n)
{
return *this += -__n;
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(difference_type __n) const
{
__bit_iterator __t(*this);
__t += __n;
return __t;
}
_LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const
{
__bit_iterator __t(*this);
__t -= __n;
return __t;
}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
{return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}
_LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](difference_type __n) const {return *(*this + __n);}
_LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
{return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}
_LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__x == __y);}
_LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
{return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}
_LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
{return __y < __x;}
_LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__y < __x);}
_LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
{return !(__x < __y);}
private:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
: __seg_(__s), __ctz_(__ctz) {}
@ -1265,26 +1272,44 @@ private:
friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, true>;
template <class _Dp> friend struct __bit_array;
template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
template <class _Dp>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
__bit_iterator<_Dp, _IC> __last,
__bit_iterator<_Dp, false> __result);
template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,
__bit_iterator<__C1, false>,
__bit_iterator<__C2, false>);
@ -1294,22 +1319,32 @@ private:
template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,
__bit_iterator<__C1, false>,
__bit_iterator<__C2, false>);
template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
__bit_iterator<_Dp, false>,
__bit_iterator<_Dp, false>);
template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC2>);
template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC2>);
template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC2>);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,
typename _Dp::size_type);
template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,
typename _Dp::size_type);
template <class _Dp>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
__bit_iterator<_Dp, false>,
__bit_iterator<_Dp, false>);
template <class _Dp, bool _IC1, bool _IC2>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC2>);
template <class _Dp, bool _IC1, bool _IC2>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC2>);
template <class _Dp, bool _IC1, bool _IC2>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend bool equal(__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC2>);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
template <class _Dp, bool _IC>
_LIBCPP_CONSTEXPR_AFTER_CXX17
friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
__count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type

View File

@ -42,7 +42,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Ar
#if _LIBCPP_STD_VER > 17
return std::construct_at(__location, std::forward<_Args>(__args)...);
#else
return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"),
::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
#endif
}

View File

@ -122,7 +122,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
private:
struct __nat {};
public:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static pointer pointer_to(typename conditional<is_void<element_type>::value,
__nat, element_type>::type& __r)
{return pointer::pointer_to(__r);}

View File

@ -509,10 +509,11 @@ __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
template <class _Alloc, class _Iter>
class _AllocatorDestroyRangeReverse {
public:
_LIBCPP_HIDE_FROM_ABI _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
_AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
: __alloc_(__alloc), __first_(__first), __last_(__last) {}
_LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
}
@ -621,7 +622,7 @@ template <
class _Type = typename iterator_traits<_Iter1>::value_type,
class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
__allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
if (__libcpp_is_constant_evaluated()) {
while (__first1 != __last1) {

View File

@ -62,107 +62,107 @@ public:
typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
_LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
_LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
_LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
_LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
explicit __split_buffer(__alloc_rr& __a);
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
explicit __split_buffer(const __alloc_rr& __a);
__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
~__split_buffer();
_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
_LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer();
__split_buffer(__split_buffer&& __c)
_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
__split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
__split_buffer& operator=(__split_buffer&& __c)
_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
_LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c)
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<allocator_type>::value) ||
!__alloc_traits::propagate_on_container_move_assignment::value);
_LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
_LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
_LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{__destruct_at_end(__begin_);}
_LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
_LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
_LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
_LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
_LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
_LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
_LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
_LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
_LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
void reserve(size_type __n);
void shrink_to_fit() _NOEXCEPT;
void push_front(const_reference __x);
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
void push_front(value_type&& __x);
void push_back(value_type&& __x);
_LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
_LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
_LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x);
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
_LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x);
_LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x);
template <class... _Args>
void emplace_back(_Args&&... __args);
_LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args);
_LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
_LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
void __construct_at_end(size_type __n);
void __construct_at_end(size_type __n, const_reference __x);
_LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
_LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x);
template <class _InputIter>
__enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__construct_at_end(_InputIter __first, _InputIter __last);
template <class _ForwardIterator>
__enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
_LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
{__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_begin(pointer __new_begin, false_type);
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_begin(pointer __new_begin, true_type);
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last) _NOEXCEPT
{__destruct_at_end(__new_last, false_type());}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
void swap(__split_buffer& __x)
_LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
__is_nothrow_swappable<__alloc_rr>::value);
bool __invariants() const;
_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
private:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__split_buffer& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
__alloc() = _VSTD::move(__c.__alloc());
}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
{}
struct _ConstructTransaction {
explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
: __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
}
~_ConstructTransaction() {
_LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
*__dest_ = __pos_;
}
pointer __pos_;
@ -173,6 +173,7 @@ private:
};
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
bool
__split_buffer<_Tp, _Allocator>::__invariants() const
{
@ -203,6 +204,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
@ -219,6 +221,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
@ -231,7 +234,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
template <class _Tp, class _Allocator>
template <class _InputIter>
__enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
{
__alloc_rr& __a = this->__alloc();
@ -254,7 +257,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
__enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
_ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
@ -265,6 +268,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
@ -274,6 +278,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
@ -282,6 +287,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
@ -291,6 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
@ -299,6 +306,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
@ -314,6 +322,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
@ -322,6 +331,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@ -329,6 +339,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@ -336,6 +347,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::~__split_buffer()
{
clear();
@ -344,6 +356,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
: __first_(_VSTD::move(__c.__first_)),
@ -358,6 +371,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
: __end_cap_(nullptr, __a)
{
@ -384,6 +398,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
__split_buffer<_Tp, _Allocator>&
__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
@ -404,6 +419,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
@ -417,6 +433,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
{
@ -433,6 +450,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
{
@ -460,6 +478,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
{
@ -489,6 +508,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
{
@ -519,6 +539,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
@ -549,6 +570,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
{
@ -580,6 +602,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
template <class _Tp, class _Allocator>
template <class... _Args>
_LIBCPP_CONSTEXPR_AFTER_CXX17
void
__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
@ -610,6 +633,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
}
template <class _Tp, class _Allocator>
_LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
void
swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)

View File

@ -838,6 +838,8 @@ template<size_t N, class T>
*/
#include <__algorithm/copy.h>
#include <__algorithm/move.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__memory/addressof.h>
@ -941,21 +943,31 @@ template <class _Tp, class _Alloc>
struct __temp_value {
typedef allocator_traits<_Alloc> _Traits;
#ifdef _LIBCPP_CXX03_LANG
typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
#else
union { _Tp __v; };
#endif
_Alloc &__a;
_Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
_Tp & get() { return *__addr(); }
_LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() {
#ifdef _LIBCPP_CXX03_LANG
return reinterpret_cast<_Tp*>(std::addressof(__v));
#else
return std::addressof(__v);
#endif
}
_LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp & get() { return *__addr(); }
template<class... _Args>
_LIBCPP_NO_CFI
__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
_Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
_VSTD::forward<_Args>(__args)...);
_LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
_Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
}
~__temp_value() { _Traits::destroy(__a, __addr()); }
};
_LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); }
};
template<typename _Alloc, typename = void, typename = void>
struct __is_allocator : false_type {};

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,11 @@ public:
typedef _Tp* pointer;
typedef _Tp value_type;
template <class U>
struct rebind {
using other = __sso_allocator<U, _Np>;
};
_LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
_LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()

View File

@ -12,6 +12,8 @@
// map& operator=(const map& m);
// XFAIL: libcpp-has-debug-mode
#include <map>
#include <algorithm>
#include <cassert>

View File

@ -16,7 +16,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5));
@ -42,5 +42,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> d;
@ -39,5 +39,14 @@ int main(int, char**)
assert(d[3] == true);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
@ -77,5 +77,14 @@ int main(int, char**)
assert(l2.get_allocator() == lo.get_allocator());
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v;
@ -42,5 +42,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,7 +20,7 @@
#include "test_comparisons.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool test() {
typedef std::vector<bool> VB;
{
const VB v1, v2;
@ -76,5 +76,14 @@ int main(int, char**) {
assert( (std::vector<bool>() >= std::vector<bool>()));
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -13,7 +13,7 @@
#include "test_macros.h"
bool test() {
TEST_CONSTEXPR_CXX20 bool test() {
using CRefT = std::vector<bool>::const_reference;
#if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL)
ASSERT_SAME_TYPE(CRefT, bool);
@ -32,6 +32,9 @@ bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -24,8 +24,7 @@
#include "min_allocator.h"
template <class C>
void
test0()
TEST_CONSTEXPR_CXX20 void test0()
{
#if TEST_STD_VER > 14
LIBCPP_STATIC_ASSERT((noexcept(C{})), "" );
@ -45,8 +44,7 @@ test0()
}
template <class C>
void
test1(const typename C::allocator_type& a)
TEST_CONSTEXPR_CXX20 void test1(const typename C::allocator_type& a)
{
#if TEST_STD_VER > 14
LIBCPP_STATIC_ASSERT((noexcept(C{typename C::allocator_type{}})), "" );
@ -59,7 +57,7 @@ test1(const typename C::allocator_type& a)
assert(c.get_allocator() == a);
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
test0<std::vector<bool> >();
@ -76,5 +74,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,8 +20,7 @@
#include "min_allocator.h"
template <class C, class Iterator>
void
test(Iterator first, Iterator last)
TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last)
{
C c(first, last);
LIBCPP_ASSERT(c.__invariants());
@ -30,7 +29,7 @@ test(Iterator first, Iterator last)
assert(*i == *first);
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
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]);
@ -47,5 +46,14 @@ int main(int, char**)
test<std::vector<bool, min_allocator<bool>> >(a, an);
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -21,8 +21,7 @@
#include "min_allocator.h"
template <class C, class Iterator>
void
test(Iterator first, Iterator last, const typename C::allocator_type& a)
TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last, const typename C::allocator_type& a)
{
C c(first, last, a);
LIBCPP_ASSERT(c.__invariants());
@ -31,7 +30,7 @@ test(Iterator first, Iterator last, const typename C::allocator_type& a)
assert(*i == *first);
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
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]);
@ -54,5 +53,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,9 +19,8 @@
#include "test_allocator.h"
template <class C>
void
test2(typename C::size_type n,
typename C::allocator_type const& a = typename C::allocator_type ())
TEST_CONSTEXPR_CXX20 void test2(typename C::size_type n,
typename C::allocator_type const& a = typename C::allocator_type ())
{
#if TEST_STD_VER >= 14
C c(n, a);
@ -37,8 +36,7 @@ test2(typename C::size_type n,
}
template <class C>
void
test1(typename C::size_type n)
TEST_CONSTEXPR_CXX20 void test1(typename C::size_type n)
{
C c(n);
LIBCPP_ASSERT(c.__invariants());
@ -49,14 +47,13 @@ test1(typename C::size_type n)
}
template <class C>
void
test(typename C::size_type n)
TEST_CONSTEXPR_CXX20 void test(typename C::size_type n)
{
test1<C> ( n );
test2<C> ( n );
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
test<std::vector<bool> >(50);
#if TEST_STD_VER >= 11
@ -64,5 +61,14 @@ int main(int, char**)
test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23));
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,8 +18,7 @@
#include "min_allocator.h"
template <class C>
void
test(typename C::size_type n, const typename C::value_type& x)
TEST_CONSTEXPR_CXX20 void test(typename C::size_type n, const typename C::value_type& x)
{
C c(n, x);
LIBCPP_ASSERT(c.__invariants());
@ -28,12 +27,21 @@ test(typename C::size_type n, const typename C::value_type& x)
assert(*i == x);
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
test<std::vector<bool> >(50, true);
#if TEST_STD_VER >= 11
test<std::vector<bool, min_allocator<bool>> >(50, true);
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,9 +18,9 @@
#include "min_allocator.h"
template <class C>
void
test(typename C::size_type n, const typename C::value_type& x,
const typename C::allocator_type& a)
TEST_CONSTEXPR_CXX20 void test(typename C::size_type n,
const typename C::value_type& x,
const typename C::allocator_type& a)
{
C c(n, x, a);
LIBCPP_ASSERT(c.__invariants());
@ -30,12 +30,21 @@ test(typename C::size_type n, const typename C::value_type& x,
assert(*i == x);
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
test<std::vector<bool> >(50, true, std::allocator<bool>());
#if TEST_STD_VER >= 11
test<std::vector<bool, min_allocator<bool>> >(50, true, min_allocator<bool>());
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,8 +19,7 @@
#include "min_allocator.h"
template <class C>
void
test(const C& x)
TEST_CONSTEXPR_CXX20 void test(const C& x)
{
typename C::size_type s = x.size();
C c(x);
@ -29,7 +28,7 @@ test(const C& x)
assert(c == x);
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
@ -62,5 +61,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,8 +18,7 @@
#include "min_allocator.h"
template <class C>
void
test(const C& x, const typename C::allocator_type& a)
TEST_CONSTEXPR_CXX20 void test(const C& x, const typename C::allocator_type& a)
{
typename C::size_type s = x.size();
C c(x, a);
@ -28,7 +27,7 @@ test(const C& x, const typename C::allocator_type& a)
assert(c == x);
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
@ -61,5 +60,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef std::vector<bool> C;
@ -65,5 +65,14 @@ int main(int, char**)
assert(c.back() == true);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef std::vector<bool> C;
@ -88,5 +88,14 @@ int main(int, char**)
assert(c.back() == true);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef std::vector<bool> C;
@ -43,5 +43,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,12 +19,19 @@
#include "test_macros.h"
#include "min_allocator.h"
TEST_CONSTEXPR_CXX20 bool test() {
test_hash_enabled_for_type<std::vector<bool> >();
test_hash_enabled_for_type<std::vector<bool, min_allocator<bool>>>();
return true;
}
int main(int, char**) {
test_library_hash_specializations_available();
{
test_hash_enabled_for_type<std::vector<bool> >();
test_hash_enabled_for_type<std::vector<bool, min_allocator<bool>>>();
}
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
bool a1[] = {1, 0, 1};
{
@ -64,5 +64,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
bool a1[] = {1, 0, 1};
{
@ -84,5 +84,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,7 +20,7 @@
#include "test_macros.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
for (unsigned i = 1; i < 256; ++i)
@ -41,5 +41,14 @@ int main(int, char**)
}
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "test_macros.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool test() {
{
std::allocator<bool> alloc;
const std::vector<bool> vb(alloc);
@ -30,5 +30,14 @@ int main(int, char**) {
assert(vb.get_allocator() == alloc);
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> d = {true, false, false, true};
@ -37,5 +37,14 @@ int main(int, char**)
assert(d[3] == true);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
@ -40,5 +40,14 @@ int main(int, char**)
assert(d[3] == true);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> d(10, true);
@ -61,5 +61,14 @@ int main(int, char**)
assert(d[13] == true);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,7 +20,7 @@
#include "test_iterators.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v(100);
@ -142,5 +142,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v(100);
@ -87,5 +87,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v(100);
@ -84,5 +84,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -22,7 +22,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
using IterRefT = std::iterator_traits<std::vector<bool>::iterator>::reference;
ASSERT_SAME_TYPE(IterRefT, std::vector<bool>::reference);
@ -66,6 +66,8 @@ int main(int, char**)
typedef std::vector<T> C;
C::iterator i;
C::const_iterator j;
(void) i;
(void) j;
}
#if TEST_STD_VER >= 11
{
@ -101,6 +103,8 @@ int main(int, char**)
typedef std::vector<T, min_allocator<T>> C;
C::iterator i;
C::const_iterator j;
(void) i;
(void) j;
}
#endif
#if TEST_STD_VER > 11
@ -130,5 +134,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
test_allocator_statistics alloc_stats;
{
@ -91,5 +91,14 @@ int main(int, char**)
}
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
@ -73,5 +73,14 @@ int main(int, char**)
assert(l2.get_allocator() == min_allocator<bool>());
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> d;
@ -39,5 +39,14 @@ int main(int, char**)
assert(d[3] == true);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
bool a[] = {0, 1, 1, 0, 1, 0, 0};
@ -47,5 +47,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -16,7 +16,7 @@
#include "test_macros.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
bool a[] = {false, true, false, true};
@ -36,5 +36,14 @@ int main(int, char**)
assert( r1);
assert(!r2);
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -15,7 +15,7 @@
#include "test_macros.h"
bool test() {
TEST_CONSTEXPR_CXX20 bool test() {
std::vector<bool> vec;
typedef std::vector<bool>::reference Ref;
vec.push_back(true);
@ -47,6 +47,9 @@ bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -13,7 +13,9 @@
#include <cassert>
#include <vector>
bool test() {
#include "test_macros.h"
TEST_CONSTEXPR_CXX20 bool test() {
std::vector<bool> vec;
typedef std::vector<bool>::reference Ref;
vec.push_back(true);
@ -71,6 +73,9 @@ bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -13,7 +13,9 @@
#include <cassert>
#include <vector>
bool test() {
#include "test_macros.h"
TEST_CONSTEXPR_CXX20 bool test() {
std::vector<bool> vec;
typedef std::vector<bool>::reference Ref;
vec.push_back(true);
@ -28,6 +30,9 @@ bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -13,7 +13,9 @@
#include <cassert>
#include <vector>
bool test() {
#include "test_macros.h"
TEST_CONSTEXPR_CXX20 bool test() {
std::vector<bool> vec;
typedef std::vector<bool>::reference Ref;
vec.push_back(true);
@ -33,6 +35,9 @@ bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -14,7 +14,9 @@
#include <type_traits>
#include <vector>
bool test() {
#include "test_macros.h"
TEST_CONSTEXPR_CXX20 bool test() {
std::vector<bool> vec;
typedef std::vector<bool>::reference Ref;
static_assert(std::is_convertible<Ref, bool>::value, "");
@ -33,6 +35,9 @@ bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -19,7 +19,7 @@
#include "min_allocator.h"
#include "test_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v;
@ -59,7 +59,7 @@ int main(int, char**)
}
#endif
#ifndef TEST_HAS_NO_EXCEPTIONS
{
if (!TEST_IS_CONSTANT_EVALUATED) {
std::vector<bool, limited_allocator<bool, 10> > v;
v.reserve(5);
try {
@ -76,5 +76,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v(100);
@ -54,5 +54,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v(100);
@ -50,5 +50,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v(100);
@ -36,5 +36,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef std::vector<bool> C;
@ -59,5 +59,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<bool> v1(100);
@ -96,5 +96,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -24,7 +24,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef std::vector<bool> T;
@ -56,5 +56,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -29,9 +29,7 @@
#include "test_macros.h"
template <class C>
C
make(int size, int start)
{
TEST_CONSTEXPR_CXX20 C make(int size, int start) {
C c;
for (int i = 0; i < size; ++i)
c.push_back(start + i);
@ -39,7 +37,7 @@ make(int size, int start)
}
template <class Vector>
void test_get_basic(Vector& c, int start_value) {
TEST_CONSTEXPR_CXX20 void test_get_basic(Vector& c, int start_value) {
const int n = static_cast<int>(c.size());
for (int i = 0; i < n; ++i)
assert(c[i] == start_value + i);
@ -47,10 +45,12 @@ void test_get_basic(Vector& c, int start_value) {
assert(c.at(i) == start_value + i);
#ifndef TEST_HAS_NO_EXCEPTIONS
try {
TEST_IGNORE_NODISCARD c.at(n);
assert(false);
} catch (const std::out_of_range&) {}
if (!TEST_IS_CONSTANT_EVALUATED) {
try {
TEST_IGNORE_NODISCARD c.at(n);
assert(false);
} catch (const std::out_of_range&) {}
}
#endif
assert(c.front() == start_value);
@ -58,7 +58,7 @@ void test_get_basic(Vector& c, int start_value) {
}
template <class Vector>
void test_get() {
TEST_CONSTEXPR_CXX20 void test_get() {
int start_value = 35;
Vector c = make<Vector>(10, start_value);
const Vector& cc = c;
@ -67,7 +67,7 @@ void test_get() {
}
template <class Vector>
void test_set() {
TEST_CONSTEXPR_CXX20 void test_set() {
int start_value = 35;
const int n = 10;
Vector c = make<Vector>(n, start_value);
@ -93,7 +93,7 @@ void test_set() {
}
template <class Vector>
void test() {
TEST_CONSTEXPR_CXX20 void test() {
test_get<Vector>();
test_set<Vector>();
@ -112,12 +112,18 @@ void test() {
ASSERT_SAME_TYPE(typename Vector::const_reference, decltype(cc.back()));
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
test<std::vector<int> >();
#if TEST_STD_VER >= 11
test<std::vector<int, min_allocator<int> > >();
#endif
return 0;
return true;
}
int main(int, char**) {
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,7 +20,7 @@
#include "test_comparisons.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool test() {
{
const std::vector<int> c1, c2;
assert(testComparisons(c1, c2, true, false));
@ -116,5 +116,14 @@ int main(int, char**) {
assert((std::vector<int>() >= std::vector<int>()));
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// XFAIL: libcpp-has-debug-mode
#include <algorithm>
#include <vector>
std::vector<int> ca_allocs;
int main(int, char**) {
ca_allocs.push_back(0);
for ([[maybe_unused]] const auto& a : ca_allocs)
;
return 0;
}

View File

@ -18,13 +18,13 @@
#include "min_allocator.h"
template <class C>
void test_contiguous ( const C &c )
TEST_CONSTEXPR_CXX20 void test_contiguous(const C &c)
{
for ( size_t i = 0; i < c.size(); ++i )
assert ( *(c.begin() + static_cast<typename C::difference_type>(i)) == *(std::addressof(*c.begin()) + i));
}
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef int T;
@ -50,5 +50,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "test_macros.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool test() {
{
std::allocator<int> alloc;
const std::vector<int> v(alloc);
@ -30,5 +30,14 @@ int main(int, char**) {
assert(v.get_allocator() == alloc);
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -28,7 +28,7 @@ struct A
int second;
};
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef int T;
@ -167,5 +167,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -22,7 +22,7 @@
#include "min_allocator.h"
template <class Vector>
void check_vector_reverse_iterators() {
TEST_CONSTEXPR_CXX20 void check_vector_reverse_iterators() {
{
Vector vec;
assert(vec.rbegin() == vec.rend());
@ -67,11 +67,20 @@ void check_vector_reverse_iterators() {
}
}
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool test() {
check_vector_reverse_iterators<std::vector<int> >();
#if TEST_STD_VER >= 11
check_vector_reverse_iterators<std::vector<int, min_allocator<int> > >();
#endif
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<int> v;
@ -46,5 +46,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,8 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
typedef std::vector<int> C;
C c;
@ -43,5 +42,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,7 +19,7 @@
#include "test_macros.h"
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef limited_allocator<int, 10> A;
typedef std::vector<int, A> C;
@ -45,5 +45,15 @@ int main(int, char**) {
assert(c.max_size() <= alloc_max_size(c.get_allocator()));
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -18,8 +18,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
std::vector<int> v;
v.reserve(10);
@ -50,7 +49,7 @@ int main(int, char**)
assert(is_contiguous_container_asan_correct(v));
}
#ifndef TEST_HAS_NO_EXCEPTIONS
{
if (!TEST_IS_CONSTANT_EVALUATED) {
std::vector<int> v;
size_t sz = v.max_size() + 1;
@ -62,7 +61,7 @@ int main(int, char**)
assert(v.capacity() == 0);
}
}
{
if (!TEST_IS_CONSTANT_EVALUATED) {
std::vector<int> v(10, 42);
int* previous_data = v.data();
size_t previous_capacity = v.capacity();
@ -102,7 +101,7 @@ int main(int, char**)
}
#endif
#ifndef TEST_HAS_NO_EXCEPTIONS
{
if (!TEST_IS_CONSTANT_EVALUATED) {
std::vector<int, limited_allocator<int, 100> > v;
v.reserve(50);
assert(v.capacity() == 50);
@ -118,5 +117,16 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,8 +19,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
std::vector<int> v(100);
v.resize(50);
@ -81,5 +80,16 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,8 +17,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
std::vector<int> v(100);
v.resize(50, 1);
@ -75,5 +74,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,8 +17,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
std::vector<int> v(100);
v.push_back(1);
@ -38,7 +37,7 @@ int main(int, char**)
assert(is_contiguous_container_asan_correct(v));
}
#ifndef TEST_HAS_NO_EXCEPTIONS
{
if (!TEST_IS_CONSTANT_EVALUATED) {
std::vector<int, limited_allocator<int, 400> > v(100);
v.push_back(1);
assert(is_contiguous_container_asan_correct(v));
@ -60,5 +59,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef std::vector<int> C;
@ -59,5 +59,14 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,8 +17,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
std::vector<int> v1(100);
std::vector<int> v2(200);
@ -48,5 +47,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -17,8 +17,7 @@
#include "min_allocator.h"
#include "allocators.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
@ -81,5 +80,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,7 +20,7 @@
#include "asan_testing.h"
template <typename Vec>
void test ( Vec &v )
TEST_CONSTEXPR_CXX20 void test(Vec &v)
{
v.assign({3, 4, 5, 6});
assert(v.size() == 4);
@ -31,8 +31,7 @@ void test ( Vec &v )
assert(v[3] == 6);
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
typedef std::vector<int> V;
V d1;
@ -50,5 +49,14 @@ int main(int, char**)
test(d2);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -23,7 +23,7 @@
#endif
void test() {
TEST_CONSTEXPR_CXX20 bool test() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@ -77,9 +77,14 @@ void test() {
dst.assign(It(src.data()), It(src.data() + src.size()));
assert(dst == src);
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}

View File

@ -20,8 +20,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@ -97,5 +96,14 @@ int main(int, char**)
assert(is_contiguous_container_asan_correct(l2));
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,10 +18,10 @@
#include "min_allocator.h"
#include "asan_testing.h"
bool is6(int x) { return x == 6; }
TEST_CONSTEXPR bool is6(int x) { return x == 6; }
template <typename Vec>
void test ( Vec &v )
TEST_CONSTEXPR_CXX20 void test(Vec &v)
{
v.assign(5, 6);
assert(v.size() == 5);
@ -29,8 +29,7 @@ void test ( Vec &v )
assert(std::all_of(v.begin(), v.end(), is6));
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
typedef std::vector<int> V;
V d1;
@ -56,5 +55,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -22,8 +22,7 @@
#include "asan_testing.h"
template <class C>
void
test0()
TEST_CONSTEXPR_CXX20 void test0()
{
#if TEST_STD_VER > 14
static_assert((noexcept(C{})), "" );
@ -45,8 +44,7 @@ test0()
}
template <class C>
void
test1(const typename C::allocator_type& a)
TEST_CONSTEXPR_CXX20 void test1(const typename C::allocator_type& a)
{
#if TEST_STD_VER > 14
static_assert((noexcept(C{typename C::allocator_type{}})), "" );
@ -60,8 +58,7 @@ test1(const typename C::allocator_type& a)
LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
test0<std::vector<int> >();
test0<std::vector<NotConstructible> >();
@ -99,5 +96,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -25,7 +25,7 @@
#endif
template <class C, class Iterator>
void test(Iterator first, Iterator last) {
TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last) {
{
C c(first, last);
LIBCPP_ASSERT(c.__invariants());
@ -44,7 +44,7 @@ void test(Iterator first, Iterator last) {
}
}
static void basic_test_cases() {
TEST_CONSTEXPR_CXX20 void basic_test_cases() {
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> >(cpp17_input_iterator<const int*>(a),
@ -84,7 +84,7 @@ static void basic_test_cases() {
#endif
}
void emplaceable_concept_tests() {
TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@ -160,7 +160,7 @@ struct B2 { int y; };
struct Der : B1, B2 { int z; };
// Initialize a vector with a different value type.
void test_ctor_with_different_value_type() {
TEST_CONSTEXPR_CXX20 void test_ctor_with_different_value_type() {
{
// Make sure initialization is performed with each element value, not with
// a memory blob.
@ -189,12 +189,20 @@ void test_ctor_with_different_value_type() {
}
}
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool tests() {
basic_test_cases();
emplaceable_concept_tests(); // See PR34898
test_ctor_under_alloc();
test_ctor_with_different_value_type();
return 0;
return true;
}
int main(int, char**)
{
tests();
test_ctor_under_alloc();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -26,7 +26,7 @@
#endif
template <class C, class Iterator, class A>
void test(Iterator first, Iterator last, const A& a) {
TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last, const A& a) {
C c(first, last, a);
LIBCPP_ASSERT(c.__invariants());
assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
@ -40,16 +40,16 @@ void test(Iterator first, Iterator last, const A& a) {
template <class T>
struct implicit_conv_allocator : min_allocator<T> {
implicit_conv_allocator(void*) {}
implicit_conv_allocator(const implicit_conv_allocator&) = default;
TEST_CONSTEXPR implicit_conv_allocator(void*) {}
TEST_CONSTEXPR implicit_conv_allocator(const implicit_conv_allocator&) = default;
template <class U>
implicit_conv_allocator(implicit_conv_allocator<U>) {}
TEST_CONSTEXPR implicit_conv_allocator(implicit_conv_allocator<U>) {}
};
#endif
void basic_tests() {
TEST_CONSTEXPR_CXX20 void basic_tests() {
{
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]);
@ -86,7 +86,7 @@ void basic_tests() {
#endif
}
void emplaceable_concept_tests() {
TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@ -162,9 +162,18 @@ void test_ctor_under_alloc() {
#endif
}
int main(int, char**) {
TEST_CONSTEXPR_CXX20 bool test() {
basic_tests();
emplaceable_concept_tests(); // See PR34898
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
test_ctor_under_alloc();
return 0;

View File

@ -21,6 +21,7 @@
#include "asan_testing.h"
template <class C>
TEST_CONSTEXPR_CXX20
void test(typename C::size_type n,
typename C::allocator_type const& a = typename C::allocator_type())
{
@ -52,24 +53,33 @@ void test(typename C::size_type n,
#endif
}
void tests() {
TEST_CONSTEXPR_CXX20 bool tests() {
test<std::vector<int> >(0);
test<std::vector<int> >(50);
test<std::vector<DefaultOnly> >(0);
test<std::vector<DefaultOnly> >(500);
assert(DefaultOnly::count == 0);
#if TEST_STD_VER >= 11
test<std::vector<int, min_allocator<int>>>(0);
test<std::vector<int, min_allocator<int>>>(50);
#endif
return true;
}
int main(int, char**) {
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
test<std::vector<DefaultOnly> >(0);
test<std::vector<DefaultOnly> >(500);
assert(DefaultOnly::count == 0);
#if TEST_STD_VER >= 11
test<std::vector<DefaultOnly, min_allocator<DefaultOnly>>>(0);
test<std::vector<DefaultOnly, min_allocator<DefaultOnly>>>(500);
test<std::vector<DefaultOnly, test_allocator<DefaultOnly>>>(0, test_allocator<DefaultOnly>(23));
test<std::vector<DefaultOnly, test_allocator<DefaultOnly>>>(100, test_allocator<DefaultOnly>(23));
assert(DefaultOnly::count == 0);
#endif
}
int main(int, char**) {
tests();
return 0;
}

View File

@ -19,7 +19,7 @@
#include "asan_testing.h"
template <class C>
void
TEST_CONSTEXPR_CXX20 void
test(typename C::size_type n, const typename C::value_type& x)
{
C c(n, x);
@ -30,8 +30,7 @@ test(typename C::size_type n, const typename C::value_type& x)
assert(*i == x);
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
test<std::vector<int> >(0, 3);
test<std::vector<int> >(50, 3);
// Add 1 for implementations that dynamically allocate a container proxy.
@ -43,5 +42,14 @@ int main(int, char**)
test<std::vector<int, min_allocator<int>> >(50, 3);
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "asan_testing.h"
template <class C>
void
TEST_CONSTEXPR_CXX20 void
test(typename C::size_type n, const typename C::value_type& x,
const typename C::allocator_type& a)
{
@ -31,8 +31,7 @@ test(typename C::size_type n, const typename C::value_type& x,
assert(*i == x);
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
test<std::vector<int> >(0, 3, std::allocator<int>());
test<std::vector<int> >(50, 3, std::allocator<int>());
#if TEST_STD_VER >= 11
@ -40,5 +39,14 @@ int main(int, char**)
test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,7 +19,7 @@
#include "asan_testing.h"
template <class C>
void
TEST_CONSTEXPR_CXX20 void
test(const C& x)
{
typename C::size_type s = x.size();
@ -30,8 +30,7 @@ test(const C& x)
LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
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]);
@ -87,5 +86,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -19,7 +19,7 @@
#include "asan_testing.h"
template <class C>
void
TEST_CONSTEXPR_CXX20 void
test(const C& x, const typename C::allocator_type& a)
{
typename C::size_type s = x.size();
@ -30,8 +30,7 @@ test(const C& x, const typename C::allocator_type& a)
LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
}
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
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]);
@ -71,5 +70,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -28,8 +28,7 @@
struct A {};
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
// Test the explicit deduction guides
{
@ -143,5 +142,13 @@ int main(int, char**)
SequenceContainerDeductionGuidesSfinaeAway<std::vector, std::vector<int>>();
return true;
}
int main(int, char**) {
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -22,5 +22,5 @@ struct X
int main(int, char**)
{
return 0;
return 0;
}

View File

@ -30,8 +30,7 @@ struct some_alloc
void allocate(size_t);
};
int main(int, char**)
{
TEST_CONSTEXPR_CXX20 bool tests() {
{
typedef std::vector<MoveOnly> C;
static_assert(std::is_nothrow_default_constructible<C>::value, "");
@ -49,5 +48,14 @@ int main(int, char**)
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -28,7 +28,7 @@ struct some_alloc
void allocate(size_t);
};
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
typedef std::vector<MoveOnly> C;
@ -49,5 +49,14 @@ int main(int, char**)
}
#endif // _LIBCPP_VERSION
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<int> d = {3, 4, 5, 6};
@ -39,5 +39,14 @@ int main(int, char**)
assert(d[3] == 6);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,7 +20,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
@ -49,5 +49,14 @@ int main(int, char**)
assert(is_contiguous_container_asan_correct(d));
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -21,7 +21,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
test_allocator_statistics alloc_stats;
{
@ -131,5 +131,14 @@ int main(int, char**)
}
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -20,7 +20,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
@ -95,5 +95,14 @@ int main(int, char**)
assert(is_contiguous_container_asan_correct(l2));
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -96,5 +96,5 @@ int main(int, char**)
}
#endif
return 0;
return 0;
}

View File

@ -19,7 +19,7 @@
#include "min_allocator.h"
#include "asan_testing.h"
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<int> d;
@ -42,5 +42,14 @@ int main(int, char**)
assert(d[3] == 6);
}
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,15 +18,15 @@
#include "asan_testing.h"
struct Nasty {
Nasty() : i_(0) {}
Nasty(int i) : i_(i) {}
~Nasty() {}
TEST_CONSTEXPR Nasty() : i_(0) {}
TEST_CONSTEXPR Nasty(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 ~Nasty() {}
Nasty * operator&() const { assert(false); return nullptr; }
int i_;
};
};
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
std::vector<int> v;
@ -61,5 +61,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

View File

@ -18,15 +18,15 @@
#include "asan_testing.h"
struct Nasty {
Nasty() : i_(0) {}
Nasty(int i) : i_(i) {}
~Nasty() {}
TEST_CONSTEXPR Nasty() : i_(0) {}
TEST_CONSTEXPR Nasty(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 ~Nasty() {}
Nasty * operator&() const { assert(false); return nullptr; }
int i_;
};
};
int main(int, char**)
TEST_CONSTEXPR_CXX20 bool tests()
{
{
const std::vector<int> v;
@ -61,5 +61,14 @@ int main(int, char**)
}
#endif
return 0;
return true;
}
int main(int, char**)
{
tests();
#if TEST_STD_VER > 17
static_assert(tests());
#endif
return 0;
}

Some files were not shown because too many files have changed in this diff Show More