Hello all, This side project is definitely showing me a few of my shortcomings as a programmer, so please bear with me while I try to learn. I have an implementation of constexpr vector which works in the null case, but fails on any case when it is constructed with contents or has contents added. diff --git a/include/ChangeLog b/include/ChangeLog index 41e3b76766e..d24b105b145 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -22,6 +22,11 @@ * dwarf2.h (enum dwarf_sect_v5): A new enum section for the sections in a DWARF 5 DWP file (DWP version 5). +2020-09-09 Caroline Tice <cmtice@xxxxxxxxxx> + + * dwarf2.h (enum dwarf_sect_v5): A new enum section for the + sections in a DWARF 5 DWP file (DWP version 5). + 2020-09-08 Felix Willgerodt <felix.willgerodt@xxxxxxxxx> * floatformat.h (floatformat_bfloat16_big): New. diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index 86d8ed221ff..e989637aeb7 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -717,6 +717,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template<typename _ForwardIterator, typename _Allocator> + _GLIBCXX20_CONSTEXPR void _Destroy(_ForwardIterator __first, _ForwardIterator __last, _Allocator& __alloc) @@ -731,7 +732,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _ForwardIterator, typename _Tp> - inline void + inline _GLIBCXX20_CONSTEXPR void _Destroy(_ForwardIterator __first, _ForwardIterator __last, allocator<_Tp>&) { diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index 651ae70a84b..8236bef15e9 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -974,6 +974,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER // Overload for deque::iterators, exploiting the "segmented-iterator // optimization". template<typename _Tp, typename _VTp> + _GLIBCXX20_CONSTEXPR void __fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first, const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last, diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index d19f68871ab..128d8d8d4ad 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -953,23 +953,24 @@ _GLIBCXX_END_NAMESPACE_CONTAINER { std::__fill_a1(__first.base(), __last.base(), __value); } template<typename _Tp, typename _VTp> + _GLIBCXX20_CONSTEXPR void __fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, const _VTp&); void + _GLIBCXX20_CONSTEXPR __fill_a1(_GLIBCXX_STD_C::_Bit_iterator, _GLIBCXX_STD_C::_Bit_iterator, const bool&); template<typename _FIte, typename _Tp> - _GLIBCXX20_CONSTEXPR - inline void + inline _GLIBCXX20_CONSTEXPR void __fill_a(_FIte __first, _FIte __last, const _Tp& __value) { std::__fill_a1(__first, __last, __value); } template<typename _Ite, typename _Seq, typename _Cat, typename _Tp> - void + _GLIBCXX20_CONSTEXPR void __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, const _Tp&); diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index d6f5435bdfb..8548b350c13 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -74,18 +74,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _Bit_type * _M_p; _Bit_type _M_mask; + _GLIBCXX20_CONSTEXPR _Bit_reference(_Bit_type * __x, _Bit_type __y) : _M_p(__x), _M_mask(__y) { } + _GLIBCXX20_CONSTEXPR _Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR _Bit_reference(const _Bit_reference&) = default; #endif + _GLIBCXX20_CONSTEXPR operator bool() const _GLIBCXX_NOEXCEPT { return !!(*_M_p & _M_mask); } + _GLIBCXX20_CONSTEXPR _Bit_reference& operator=(bool __x) _GLIBCXX_NOEXCEPT { @@ -96,24 +101,29 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR _Bit_reference& operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT { return *this = bool(__x); } + _GLIBCXX20_CONSTEXPR bool operator==(const _Bit_reference& __x) const { return bool(*this) == bool(__x); } + _GLIBCXX20_CONSTEXPR bool operator<(const _Bit_reference& __x) const { return !bool(*this) && bool(__x); } + _GLIBCXX20_CONSTEXPR void flip() _GLIBCXX_NOEXCEPT { *_M_p ^= _M_mask; } }; #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR inline void swap(_Bit_reference __x, _Bit_reference __y) noexcept { @@ -122,6 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __y = __tmp; } + _GLIBCXX20_CONSTEXPR inline void swap(_Bit_reference __x, bool& __y) noexcept { @@ -130,6 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __y = __tmp; } + _GLIBCXX20_CONSTEXPR inline void swap(bool& __x, _Bit_reference __y) noexcept { @@ -145,9 +157,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _Bit_type * _M_p; unsigned int _M_offset; + _GLIBCXX20_CONSTEXPR _Bit_iterator_base(_Bit_type * __x, unsigned int __y) : _M_p(__x), _M_offset(__y) { } + _GLIBCXX20_CONSTEXPR void _M_bump_up() { @@ -158,6 +172,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } } + _GLIBCXX20_CONSTEXPR void _M_bump_down() { @@ -168,6 +183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } } + _GLIBCXX20_CONSTEXPR void _M_incr(ptrdiff_t __i) { @@ -196,31 +212,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __x._M_offset <=> __y._M_offset; } #else - friend bool + friend _GLIBCXX20_CONSTEXPR bool operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return __x._M_p < __y._M_p || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset); } - friend bool + friend _GLIBCXX20_CONSTEXPR bool operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return !(__x == __y); } - friend bool + friend _GLIBCXX20_CONSTEXPR bool operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return __y < __x; } - friend bool + friend _GLIBCXX20_CONSTEXPR bool operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return !(__y < __x); } - friend bool + friend _GLIBCXX20_CONSTEXPR bool operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return !(__x < __y); } #endif // three-way comparison - friend ptrdiff_t + friend _GLIBCXX20_CONSTEXPR ptrdiff_t operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { return (int(_S_word_bit) * (__x._M_p - __y._M_p) @@ -238,19 +254,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif typedef _Bit_iterator iterator; + _GLIBCXX20_CONSTEXPR _Bit_iterator() : _Bit_iterator_base(0, 0) { } + _GLIBCXX20_CONSTEXPR _Bit_iterator(_Bit_type * __x, unsigned int __y) : _Bit_iterator_base(__x, __y) { } + _GLIBCXX20_CONSTEXPR iterator _M_const_cast() const { return *this; } + _GLIBCXX20_CONSTEXPR reference operator*() const { return reference(_M_p, 1UL << _M_offset); } + _GLIBCXX20_CONSTEXPR iterator& operator++() { @@ -258,6 +279,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR iterator operator++(int) { @@ -266,6 +288,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __tmp; } + _GLIBCXX20_CONSTEXPR iterator& operator--() { @@ -273,6 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR iterator operator--(int) { @@ -281,6 +305,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __tmp; } + _GLIBCXX20_CONSTEXPR iterator& operator+=(difference_type __i) { @@ -288,6 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR iterator& operator-=(difference_type __i) { @@ -295,10 +321,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR reference operator[](difference_type __i) const { return *(*this + __i); } + _GLIBCXX20_CONSTEXPR friend iterator operator+(const iterator& __x, difference_type __n) { @@ -307,10 +335,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __tmp; } + _GLIBCXX20_CONSTEXPR friend iterator operator+(difference_type __n, const iterator& __x) { return __x + __n; } + _GLIBCXX20_CONSTEXPR friend iterator operator-(const iterator& __x, difference_type __n) { @@ -331,22 +361,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif typedef _Bit_const_iterator const_iterator; + _GLIBCXX20_CONSTEXPR _Bit_const_iterator() : _Bit_iterator_base(0, 0) { } + _GLIBCXX20_CONSTEXPR _Bit_const_iterator(_Bit_type * __x, unsigned int __y) : _Bit_iterator_base(__x, __y) { } + _GLIBCXX20_CONSTEXPR _Bit_const_iterator(const _Bit_iterator& __x) : _Bit_iterator_base(__x._M_p, __x._M_offset) { } + _GLIBCXX20_CONSTEXPR _Bit_iterator _M_const_cast() const { return _Bit_iterator(_M_p, _M_offset); } + _GLIBCXX20_CONSTEXPR const_reference operator*() const { return _Bit_reference(_M_p, 1UL << _M_offset); } + _GLIBCXX20_CONSTEXPR const_iterator& operator++() { @@ -354,6 +390,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR const_iterator operator++(int) { @@ -362,6 +399,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __tmp; } + _GLIBCXX20_CONSTEXPR const_iterator& operator--() { @@ -369,6 +407,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR const_iterator operator--(int) { @@ -377,6 +416,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __tmp; } + _GLIBCXX20_CONSTEXPR const_iterator& operator+=(difference_type __i) { @@ -384,6 +424,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR const_iterator& operator-=(difference_type __i) { @@ -391,10 +432,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR const_reference operator[](difference_type __i) const { return *(*this + __i); } + _GLIBCXX20_CONSTEXPR friend const_iterator operator+(const const_iterator& __x, difference_type __n) { @@ -403,6 +446,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __tmp; } + _GLIBCXX20_CONSTEXPR friend const_iterator operator-(const const_iterator& __x, difference_type __n) { @@ -411,6 +455,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __tmp; } + _GLIBCXX20_CONSTEXPR friend const_iterator operator+(difference_type __n, const const_iterator& __x) { return __x + __n; } @@ -434,25 +479,32 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER struct { _Bit_type* _M_p; // Allow assignment from iterators (assume offset is zero): + _GLIBCXX20_CONSTEXPR void operator=(_Bit_iterator __it) { _M_p = __it._M_p; } } _M_start; #endif _Bit_iterator _M_finish; _Bit_pointer _M_end_of_storage; + _GLIBCXX20_CONSTEXPR _Bvector_impl_data() _GLIBCXX_NOEXCEPT : _M_start(), _M_finish(), _M_end_of_storage() { } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR _Bvector_impl_data(const _Bvector_impl_data&) = default; + + _GLIBCXX20_CONSTEXPR _Bvector_impl_data& operator=(const _Bvector_impl_data&) = default; + _GLIBCXX20_CONSTEXPR _Bvector_impl_data(_Bvector_impl_data&& __x) noexcept : _Bvector_impl_data(__x) { __x._M_reset(); } + _GLIBCXX20_CONSTEXPR void _M_move_data(_Bvector_impl_data&& __x) noexcept { @@ -461,10 +513,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #endif + _GLIBCXX20_CONSTEXPR void _M_reset() _GLIBCXX_NOEXCEPT { *this = _Bvector_impl_data(); } + _GLIBCXX20_CONSTEXPR void _M_swap_data(_Bvector_impl_data& __x) _GLIBCXX_NOEXCEPT { @@ -477,11 +531,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER struct _Bvector_impl : public _Bit_alloc_type, public _Bvector_impl_data { + _GLIBCXX20_CONSTEXPR _Bvector_impl() _GLIBCXX_NOEXCEPT_IF( is_nothrow_default_constructible<_Bit_alloc_type>::value) : _Bit_alloc_type() { } + _GLIBCXX20_CONSTEXPR _Bvector_impl(const _Bit_alloc_type& __a) _GLIBCXX_NOEXCEPT : _Bit_alloc_type(__a) { } @@ -489,15 +545,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L // Not defaulted, to enforce noexcept(true) even when // !is_nothrow_move_constructible<_Bit_alloc_type>. + _GLIBCXX20_CONSTEXPR _Bvector_impl(_Bvector_impl&& __x) noexcept : _Bit_alloc_type(std::move(__x)), _Bvector_impl_data(std::move(__x)) { } + _GLIBCXX20_CONSTEXPR _Bvector_impl(_Bit_alloc_type&& __a, _Bvector_impl&& __x) noexcept : _Bit_alloc_type(std::move(__a)), _Bvector_impl_data(std::move(__x)) { } #endif + _GLIBCXX20_CONSTEXPR _Bit_type* _M_end_addr() const _GLIBCXX_NOEXCEPT { @@ -510,45 +569,55 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER public: typedef _Alloc allocator_type; + _GLIBCXX20_CONSTEXPR _Bit_alloc_type& _M_get_Bit_allocator() _GLIBCXX_NOEXCEPT { return this->_M_impl; } + _GLIBCXX20_CONSTEXPR const _Bit_alloc_type& _M_get_Bit_allocator() const _GLIBCXX_NOEXCEPT { return this->_M_impl; } + _GLIBCXX20_CONSTEXPR allocator_type get_allocator() const _GLIBCXX_NOEXCEPT { return allocator_type(_M_get_Bit_allocator()); } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR _Bvector_base() = default; #else _Bvector_base() { } #endif + _GLIBCXX20_CONSTEXPR _Bvector_base(const allocator_type& __a) : _M_impl(__a) { } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR _Bvector_base(_Bvector_base&&) = default; + _GLIBCXX20_CONSTEXPR _Bvector_base(_Bvector_base&& __x, const allocator_type& __a) noexcept : _M_impl(_Bit_alloc_type(__a), std::move(__x._M_impl)) { } #endif + _GLIBCXX20_CONSTEXPR ~_Bvector_base() { this->_M_deallocate(); } protected: _Bvector_impl _M_impl; + _GLIBCXX20_CONSTEXPR _Bit_pointer _M_allocate(size_t __n) { return _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); } + _GLIBCXX20_CONSTEXPR void _M_deallocate() { @@ -563,11 +632,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR void _M_move_data(_Bvector_base&& __x) noexcept { _M_impl._M_move_data(std::move(__x._M_impl)); } #endif + _GLIBCXX20_CONSTEXPR static size_t _S_nword(size_t __n) { return (__n + int(_S_word_bit) - 1) / int(_S_word_bit); } @@ -629,6 +700,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typedef std::reverse_iterator<iterator> reverse_iterator; typedef _Alloc allocator_type; + _GLIBCXX20_CONSTEXPR allocator_type get_allocator() const { return _Base::get_allocator(); } @@ -641,21 +713,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER public: #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR vector() = default; #else vector() { } #endif + _GLIBCXX20_CONSTEXPR explicit vector(const allocator_type& __a) : _Base(__a) { } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR explicit vector(size_type __n, const allocator_type& __a = allocator_type()) : vector(__n, false, __a) { } + _GLIBCXX20_CONSTEXPR vector(size_type __n, const bool& __value, const allocator_type& __a = allocator_type()) #else @@ -669,6 +745,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_initialize_value(__value); } + _GLIBCXX20_CONSTEXPR vector(const vector& __x) : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator())) { @@ -677,13 +754,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR vector(vector&&) = default; private: + _GLIBCXX20_CONSTEXPR vector(vector&& __x, const allocator_type& __a, true_type) noexcept : _Base(std::move(__x), __a) { } + _GLIBCXX20_CONSTEXPR vector(vector&& __x, const allocator_type& __a, false_type) : _Base(__a) { @@ -698,12 +778,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } public: + _GLIBCXX20_CONSTEXPR vector(vector&& __x, const allocator_type& __a) noexcept(_Bit_alloc_traits::_S_always_equal()) : vector(std::move(__x), __a, typename _Bit_alloc_traits::is_always_equal{}) { } + _GLIBCXX20_CONSTEXPR vector(const vector& __x, const allocator_type& __a) : _Base(__a) { @@ -711,6 +793,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_copy_aligned(__x.begin(), __x.end(), begin()); } + _GLIBCXX20_CONSTEXPR vector(initializer_list<bool> __l, const allocator_type& __a = allocator_type()) : _Base(__a) @@ -723,6 +806,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> + _GLIBCXX20_CONSTEXPR vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) @@ -742,8 +826,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #endif + _GLIBCXX20_CONSTEXPR ~vector() _GLIBCXX_NOEXCEPT { } + _GLIBCXX20_CONSTEXPR vector& operator=(const vector& __x) { @@ -775,6 +861,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR vector& operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move()) { @@ -800,6 +887,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX20_CONSTEXPR vector& operator=(initializer_list<bool> __l) { @@ -812,6 +900,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // versions: one that takes a count, and one that takes a range. // The range version is a member template, so we dispatch on whether // or not the type is an integer. + _GLIBCXX20_CONSTEXPR void assign(size_type __n, const bool& __x) { _M_fill_assign(__n, __x); } @@ -819,6 +908,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> + _GLIBCXX20_CONSTEXPR void assign(_InputIterator __first, _InputIterator __last) { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } @@ -834,65 +924,80 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR void assign(initializer_list<bool> __l) { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } #endif + _GLIBCXX20_CONSTEXPR iterator begin() _GLIBCXX_NOEXCEPT { return iterator(this->_M_impl._M_start._M_p, 0); } + _GLIBCXX20_CONSTEXPR const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(this->_M_impl._M_start._M_p, 0); } + _GLIBCXX20_CONSTEXPR iterator end() _GLIBCXX_NOEXCEPT { return this->_M_impl._M_finish; } + _GLIBCXX20_CONSTEXPR const_iterator end() const _GLIBCXX_NOEXCEPT { return this->_M_impl._M_finish; } + _GLIBCXX20_CONSTEXPR reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(end()); } + _GLIBCXX20_CONSTEXPR const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(end()); } + _GLIBCXX20_CONSTEXPR reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } + _GLIBCXX20_CONSTEXPR const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR const_iterator cbegin() const noexcept { return const_iterator(this->_M_impl._M_start._M_p, 0); } + _GLIBCXX20_CONSTEXPR const_iterator cend() const noexcept { return this->_M_impl._M_finish; } + _GLIBCXX20_CONSTEXPR const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + _GLIBCXX20_CONSTEXPR const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } #endif + _GLIBCXX20_CONSTEXPR size_type size() const _GLIBCXX_NOEXCEPT { return size_type(end() - begin()); } + _GLIBCXX20_CONSTEXPR size_type max_size() const _GLIBCXX_NOEXCEPT { @@ -905,24 +1010,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ? __asize * int(_S_word_bit) : __isize); } + _GLIBCXX20_CONSTEXPR size_type capacity() const _GLIBCXX_NOEXCEPT { return size_type(const_iterator(this->_M_impl._M_end_addr(), 0) - begin()); } - _GLIBCXX_NODISCARD bool + _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR bool empty() const _GLIBCXX_NOEXCEPT { return begin() == end(); } + _GLIBCXX20_CONSTEXPR reference operator[](size_type __n) { return begin()[__n]; } + _GLIBCXX20_CONSTEXPR const_reference operator[](size_type __n) const { return begin()[__n]; } protected: + _GLIBCXX20_CONSTEXPR void _M_range_check(size_type __n) const { @@ -934,14 +1043,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } public: + _GLIBCXX20_CONSTEXPR reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; } + _GLIBCXX20_CONSTEXPR const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; } + _GLIBCXX20_CONSTEXPR void reserve(size_type __n) { @@ -951,18 +1063,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_reallocate(__n); } + _GLIBCXX20_CONSTEXPR reference front() { return *begin(); } + _GLIBCXX20_CONSTEXPR const_reference front() const { return *begin(); } + _GLIBCXX20_CONSTEXPR reference back() { return *(end() - 1); } + _GLIBCXX20_CONSTEXPR const_reference back() const { return *(end() - 1); } @@ -972,9 +1088,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // N.B. DR 464 says nothing about vector<bool> but we need something // here due to the way we are implementing DR 464 in the debug-mode // vector class. + _GLIBCXX20_CONSTEXPR void data() _GLIBCXX_NOEXCEPT { } + _GLIBCXX20_CONSTEXPR void push_back(bool __x) { @@ -984,6 +1102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_insert_aux(end(), __x); } + _GLIBCXX20_CONSTEXPR void swap(vector& __x) _GLIBCXX_NOEXCEPT { @@ -997,6 +1116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } // [23.2.5]/1, third-to-last entry in synopsis listing + _GLIBCXX20_CONSTEXPR static void swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT { @@ -1005,6 +1125,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __y = __tmp; } + _GLIBCXX20_CONSTEXPR iterator #if __cplusplus >= 201103L insert(const_iterator __position, const bool& __x = bool()) @@ -1024,6 +1145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last) @@ -1047,6 +1169,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __position, size_type __n, const bool& __x) { @@ -1061,15 +1184,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __p, initializer_list<bool> __l) { return this->insert(__p, __l.begin(), __l.end()); } #endif + _GLIBCXX20_CONSTEXPR void pop_back() { --this->_M_impl._M_finish; } + _GLIBCXX20_CONSTEXPR iterator #if __cplusplus >= 201103L erase(const_iterator __position) @@ -1078,6 +1204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif { return _M_erase(__position._M_const_cast()); } + _GLIBCXX20_CONSTEXPR iterator #if __cplusplus >= 201103L erase(const_iterator __first, const_iterator __last) @@ -1086,6 +1213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } + _GLIBCXX20_CONSTEXPR void resize(size_type __new_size, bool __x = bool()) { @@ -1096,11 +1224,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR void shrink_to_fit() { _M_shrink_to_fit(); } #endif + _GLIBCXX20_CONSTEXPR void flip() _GLIBCXX_NOEXCEPT { @@ -1109,6 +1239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER *__p = ~*__p; } + _GLIBCXX20_CONSTEXPR void clear() _GLIBCXX_NOEXCEPT { _M_erase_at_end(begin()); } @@ -1116,6 +1247,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename... _Args> #if __cplusplus > 201402L + _GLIBCXX20_CONSTEXPR reference #else void @@ -1129,6 +1261,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename... _Args> + _GLIBCXX20_CONSTEXPR iterator emplace(const_iterator __pos, _Args&&... __args) { return insert(__pos, bool(__args...)); } @@ -1136,6 +1269,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER protected: // Precondition: __first._M_offset == 0 && __result._M_offset == 0. + _GLIBCXX20_CONSTEXPR iterator _M_copy_aligned(const_iterator __first, const_iterator __last, iterator __result) @@ -1145,6 +1279,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER iterator(__q, 0)); } + _GLIBCXX20_CONSTEXPR void _M_initialize(size_type __n) { @@ -1158,6 +1293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } } + _GLIBCXX20_CONSTEXPR void _M_initialize_value(bool __x) { @@ -1167,10 +1303,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * sizeof(_Bit_type)); } + _GLIBCXX20_CONSTEXPR void _M_reallocate(size_type __n); #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR bool _M_shrink_to_fit(); #endif @@ -1195,6 +1333,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_initialize_range(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) @@ -1204,6 +1343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) @@ -1228,6 +1368,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } #endif + _GLIBCXX20_CONSTEXPR void _M_fill_assign(size_t __n, bool __x) { @@ -1244,6 +1385,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) @@ -1258,6 +1400,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) @@ -1292,10 +1435,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER std::__iterator_category(__first)); } #endif + _GLIBCXX20_CONSTEXPR void _M_fill_insert(iterator __position, size_type __n, bool __x); template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_insert_range(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag) @@ -1308,13 +1453,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void _M_insert_range(iterator __position, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); + _GLIBCXX20_CONSTEXPR void _M_insert_aux(iterator __position, bool __x); + _GLIBCXX20_CONSTEXPR size_type _M_check_len(size_type __n, const char* __s) const { @@ -1325,19 +1473,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return (__len < size() || __len > max_size()) ? max_size() : __len; } + _GLIBCXX20_CONSTEXPR void _M_erase_at_end(iterator __pos) { this->_M_impl._M_finish = __pos; } + _GLIBCXX20_CONSTEXPR iterator _M_erase(iterator __pos); + _GLIBCXX20_CONSTEXPR iterator _M_erase(iterator __first, iterator __last); }; _GLIBCXX_END_NAMESPACE_CONTAINER + _GLIBCXX20_CONSTEXPR inline void __fill_bvector(_GLIBCXX_STD_C::_Bit_type * __v, unsigned int __first, unsigned int __last, bool __x) @@ -1354,6 +1506,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER *__v &= ~__mask; } + _GLIBCXX20_CONSTEXPR inline void __fill_a1(_GLIBCXX_STD_C::_Bit_iterator __first, _GLIBCXX_STD_C::_Bit_iterator __last, const bool& __x) @@ -1383,6 +1536,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER struct hash<_GLIBCXX_STD_C::vector<bool, _Alloc>> : public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>> { + _GLIBCXX20_CONSTEXPR size_t operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>&) const noexcept; }; diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index a3ccb72078b..c2d5ef36549 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -225,7 +225,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __uninitialized_fill_n { template<typename _ForwardIterator, typename _Size, typename _Tp> - static _ForwardIterator + static _GLIBCXX20_CONSTEXPR _ForwardIterator __uninit_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { @@ -248,7 +248,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __uninitialized_fill_n<true> { template<typename _ForwardIterator, typename _Size, typename _Tp> - static _ForwardIterator + static _GLIBCXX20_CONSTEXPR _ForwardIterator __uninit_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { return std::fill_n(__first, __n, __x); } @@ -268,7 +268,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Like fill_n(), but does not require an initialized output range. */ template<typename _ForwardIterator, typename _Size, typename _Tp> - inline _ForwardIterator + inline _GLIBCXX20_CONSTEXPR _ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { typedef typename iterator_traits<_ForwardIterator>::value_type @@ -382,6 +382,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _ForwardIterator, typename _Size, typename _Tp, typename _Allocator> + _GLIBCXX20_CONSTEXPR _ForwardIterator __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, const _Tp& __x, _Allocator& __alloc) @@ -403,7 +404,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _ForwardIterator, typename _Size, typename _Tp, typename _Tp2> - inline _ForwardIterator + inline _GLIBCXX20_CONSTEXPR _ForwardIterator __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, const _Tp& __x, allocator<_Tp2>&) { return std::uninitialized_fill_n(__first, __n, __x); } diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index d3f1b1fae5c..952f140fa0a 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -94,17 +94,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER pointer _M_finish; pointer _M_end_of_storage; + _GLIBCXX20_CONSTEXPR _Vector_impl_data() _GLIBCXX_NOEXCEPT : _M_start(), _M_finish(), _M_end_of_storage() { } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR _Vector_impl_data(_Vector_impl_data&& __x) noexcept : _M_start(__x._M_start), _M_finish(__x._M_finish), _M_end_of_storage(__x._M_end_of_storage) { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); } #endif + _GLIBCXX20_CONSTEXPR void _M_copy_data(_Vector_impl_data const& __x) _GLIBCXX_NOEXCEPT { @@ -113,6 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_end_of_storage = __x._M_end_of_storage; } + _GLIBCXX20_CONSTEXPR void _M_swap_data(_Vector_impl_data& __x) _GLIBCXX_NOEXCEPT { @@ -128,11 +132,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER struct _Vector_impl : public _Tp_alloc_type, public _Vector_impl_data { + _GLIBCXX20_CONSTEXPR _Vector_impl() _GLIBCXX_NOEXCEPT_IF( is_nothrow_default_constructible<_Tp_alloc_type>::value) : _Tp_alloc_type() { } + _GLIBCXX20_CONSTEXPR _Vector_impl(_Tp_alloc_type const& __a) _GLIBCXX_NOEXCEPT : _Tp_alloc_type(__a) { } @@ -140,14 +146,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L // Not defaulted, to enforce noexcept(true) even when // !is_nothrow_move_constructible<_Tp_alloc_type>. + _GLIBCXX20_CONSTEXPR _Vector_impl(_Vector_impl&& __x) noexcept : _Tp_alloc_type(std::move(__x)), _Vector_impl_data(std::move(__x)) { } + _GLIBCXX20_CONSTEXPR _Vector_impl(_Tp_alloc_type&& __a) noexcept : _Tp_alloc_type(std::move(__a)) { } + _GLIBCXX20_CONSTEXPR _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept : _Tp_alloc_type(std::move(__a)), _Vector_impl_data(std::move(__rv)) { } @@ -160,15 +169,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type> ::size_type size_type; - static void _S_shrink(_Vector_impl&, size_type) { } - static void _S_on_dealloc(_Vector_impl&) { } + static _GLIBCXX20_CONSTEXPR void _S_shrink(_Vector_impl&, size_type) { } + static _GLIBCXX20_CONSTEXPR void _S_on_dealloc(_Vector_impl&) { } typedef _Vector_impl& _Reinit; struct _Grow { - _Grow(_Vector_impl&, size_type) { } - void _M_grew(size_type) { } + _GLIBCXX20_CONSTEXPR _Grow(_Vector_impl&, size_type) { } + _GLIBCXX20_CONSTEXPR void _M_grew(size_type) { } }; }; @@ -181,22 +190,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Adjust ASan annotation for [_M_start, _M_end_of_storage) to // mark end of valid region as __curr instead of __prev. - static void + static _GLIBCXX20_CONSTEXPR void _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr) { __sanitizer_annotate_contiguous_container(__impl._M_start, __impl._M_end_of_storage, __prev, __curr); } - static void + static _GLIBCXX20_CONSTEXPR void _S_grow(_Vector_impl& __impl, size_type __n) { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); } - static void + static _GLIBCXX20_CONSTEXPR void _S_shrink(_Vector_impl& __impl, size_type __n) { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); } - static void + static _GLIBCXX20_CONSTEXPR void _S_on_dealloc(_Vector_impl& __impl) { if (__impl._M_start) @@ -206,13 +215,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Used on reallocation to tell ASan unused capacity is invalid. struct _Reinit { - explicit _Reinit(_Vector_impl& __impl) : _M_impl(__impl) + explicit _GLIBCXX20_CONSTEXPR _Reinit(_Vector_impl& __impl) : _M_impl(__impl) { // Mark unused capacity as valid again before deallocating it. _S_on_dealloc(_M_impl); } - ~_Reinit() + _GLIBCXX20_CONSTEXPR ~_Reinit() { // Mark unused capacity as invalid after reallocation. if (_M_impl._M_start) @@ -223,25 +232,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _Vector_impl& _M_impl; #if __cplusplus >= 201103L - _Reinit(const _Reinit&) = delete; - _Reinit& operator=(const _Reinit&) = delete; + _GLIBCXX20_CONSTEXPR _Reinit(const _Reinit&) = delete; + _GLIBCXX20_CONSTEXPR _Reinit& operator=(const _Reinit&) = delete; #endif }; // Tell ASan when unused capacity is initialized to be valid. struct _Grow { + _GLIBCXX20_CONSTEXPR _Grow(_Vector_impl& __impl, size_type __n) : _M_impl(__impl), _M_n(__n) { _S_grow(_M_impl, __n); } + _GLIBCXX20_CONSTEXPR ~_Grow() { if (_M_n) _S_shrink(_M_impl, _M_n); } + _GLIBCXX20_CONSTEXPR void _M_grew(size_type __n) { _M_n -= __n; } #if __cplusplus >= 201103L - _Grow(const _Grow&) = delete; - _Grow& operator=(const _Grow&) = delete; + _GLIBCXX20_CONSTEXPR _Grow(const _Grow&) = delete; + _GLIBCXX20_CONSTEXPR _Grow& operator=(const _Grow&) = delete; #endif private: _Vector_impl& _M_impl; @@ -272,46 +284,54 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER public: typedef _Alloc allocator_type; + _GLIBCXX20_CONSTEXPR _Tp_alloc_type& _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT { return this->_M_impl; } - const _Tp_alloc_type& + const _GLIBCXX20_CONSTEXPR _Tp_alloc_type& _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT { return this->_M_impl; } + _GLIBCXX20_CONSTEXPR allocator_type get_allocator() const _GLIBCXX_NOEXCEPT { return allocator_type(_M_get_Tp_allocator()); } #if __cplusplus >= 201103L - _Vector_base() = default; + _GLIBCXX20_CONSTEXPR _Vector_base() = default; #else _Vector_base() { } #endif + _GLIBCXX20_CONSTEXPR _Vector_base(const allocator_type& __a) _GLIBCXX_NOEXCEPT : _M_impl(__a) { } // Kept for ABI compatibility. #if !_GLIBCXX_INLINE_VERSION + _GLIBCXX20_CONSTEXPR _Vector_base(size_t __n) : _M_impl() { _M_create_storage(__n); } #endif + _GLIBCXX20_CONSTEXPR _Vector_base(size_t __n, const allocator_type& __a) : _M_impl(__a) { _M_create_storage(__n); } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR _Vector_base(_Vector_base&&) = default; // Kept for ABI compatibility. # if !_GLIBCXX_INLINE_VERSION + _GLIBCXX20_CONSTEXPR _Vector_base(_Tp_alloc_type&& __a) noexcept : _M_impl(std::move(__a)) { } + _GLIBCXX20_CONSTEXPR _Vector_base(_Vector_base&& __x, const allocator_type& __a) : _M_impl(__a) { @@ -325,11 +345,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } # endif + _GLIBCXX20_CONSTEXPR _Vector_base(const allocator_type& __a, _Vector_base&& __x) : _M_impl(_Tp_alloc_type(__a), std::move(__x._M_impl)) { } #endif + _GLIBCXX20_CONSTEXPR ~_Vector_base() _GLIBCXX_NOEXCEPT { _M_deallocate(_M_impl._M_start, @@ -339,6 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER public: _Vector_impl _M_impl; + _GLIBCXX20_CONSTEXPR pointer _M_allocate(size_t __n) { @@ -346,6 +369,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer(); } + _GLIBCXX20_CONSTEXPR void _M_deallocate(pointer __p, size_t __n) { @@ -355,6 +379,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } protected: + _GLIBCXX20_CONSTEXPR void _M_create_storage(size_t __n) { @@ -449,19 +474,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{}); } - static pointer + static _GLIBCXX20_CONSTEXPR pointer _S_do_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc, true_type) noexcept { return std::__relocate_a(__first, __last, __result, __alloc); } - static pointer + static _GLIBCXX20_CONSTEXPR pointer _S_do_relocate(pointer, pointer, pointer __result, _Tp_alloc_type&, false_type) noexcept { return __result; } - static pointer + static _GLIBCXX20_CONSTEXPR pointer _S_relocate(pointer __first, pointer __last, pointer __result, _Tp_alloc_type& __alloc) noexcept { @@ -484,7 +509,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief Creates a %vector with no elements. */ #if __cplusplus >= 201103L - vector() = default; + _GLIBCXX20_CONSTEXPR vector() = default; #else vector() { } #endif @@ -494,6 +519,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @param __a An allocator object. */ explicit + _GLIBCXX20_CONSTEXPR vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT : _Base(__a) { } @@ -507,6 +533,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * constructed elements. */ explicit + _GLIBCXX20_CONSTEXPR vector(size_type __n, const allocator_type& __a = allocator_type()) : _Base(_S_check_init_len(__n, __a), __a) { _M_default_initialize(__n); } @@ -519,6 +546,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * * This constructor fills the %vector with @a __n copies of @a __value. */ + _GLIBCXX20_CONSTEXPR vector(size_type __n, const value_type& __value, const allocator_type& __a = allocator_type()) : _Base(_S_check_init_len(__n, __a), __a) @@ -550,6 +578,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * The newly-created %vector uses a copy of the allocator object used * by @a __x (unless the allocator traits dictate a different object). */ + _GLIBCXX20_CONSTEXPR vector(const vector& __x) : _Base(__x.size(), _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator())) @@ -569,9 +598,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * The contents of the moved instance are a valid, but unspecified * %vector. */ + _GLIBCXX20_CONSTEXPR vector(vector&&) noexcept = default; /// Copy constructor with alternative allocator + _GLIBCXX20_CONSTEXPR vector(const vector& __x, const allocator_type& __a) : _Base(__x.size(), __a) { @@ -582,10 +613,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } private: + _GLIBCXX20_CONSTEXPR vector(vector&& __rv, const allocator_type& __m, true_type) noexcept : _Base(__m, std::move(__rv)) { } + _GLIBCXX20_CONSTEXPR vector(vector&& __rv, const allocator_type& __m, false_type) : _Base(__m) { @@ -604,6 +637,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER public: /// Move constructor with alternative allocator + _GLIBCXX20_CONSTEXPR vector(vector&& __rv, const allocator_type& __m) noexcept( noexcept( vector(std::declval<vector&&>(), std::declval<const allocator_type&>(), @@ -622,6 +656,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * This will call the element type's copy constructor N times * (where N is @a __l.size()) and do no memory reallocation. */ + _GLIBCXX20_CONSTEXPR vector(initializer_list<value_type> __l, const allocator_type& __a = allocator_type()) : _Base(__a) @@ -650,6 +685,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> + _GLIBCXX20_CONSTEXPR vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) @@ -675,6 +711,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * not touched in any way. Managing the pointer is the user's * responsibility. */ + _GLIBCXX20_CONSTEXPR ~vector() _GLIBCXX_NOEXCEPT { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, @@ -691,6 +728,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * * Whether the allocator is copied depends on the allocator traits. */ + _GLIBCXX20_CONSTEXPR vector& operator=(const vector& __x); @@ -705,6 +743,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * * Whether the allocator is moved depends on the allocator traits. */ + _GLIBCXX20_CONSTEXPR vector& operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) { @@ -726,6 +765,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * that the resulting %vector's size is the same as the number * of elements assigned. */ + _GLIBCXX20_CONSTEXPR vector& operator=(initializer_list<value_type> __l) { @@ -745,6 +785,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * %vector and that the resulting %vector's size is the same as * the number of elements assigned. */ + _GLIBCXX20_CONSTEXPR void assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); } @@ -764,6 +805,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> + _GLIBCXX20_CONSTEXPR void assign(_InputIterator __first, _InputIterator __last) { _M_assign_dispatch(__first, __last, __false_type()); } @@ -790,6 +832,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * that the resulting %vector's size is the same as the number * of elements assigned. */ + _GLIBCXX20_CONSTEXPR void assign(initializer_list<value_type> __l) { @@ -807,6 +850,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * element in the %vector. Iteration is done in ordinary * element order. */ + _GLIBCXX20_CONSTEXPR iterator begin() _GLIBCXX_NOEXCEPT { return iterator(this->_M_impl._M_start); } @@ -816,6 +860,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * first element in the %vector. Iteration is done in ordinary * element order. */ + _GLIBCXX20_CONSTEXPR const_iterator begin() const _GLIBCXX_NOEXCEPT { return const_iterator(this->_M_impl._M_start); } @@ -825,6 +870,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * element in the %vector. Iteration is done in ordinary * element order. */ + _GLIBCXX20_CONSTEXPR iterator end() _GLIBCXX_NOEXCEPT { return iterator(this->_M_impl._M_finish); } @@ -834,6 +880,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * the last element in the %vector. Iteration is done in * ordinary element order. */ + _GLIBCXX20_CONSTEXPR const_iterator end() const _GLIBCXX_NOEXCEPT { return const_iterator(this->_M_impl._M_finish); } @@ -843,6 +890,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * last element in the %vector. Iteration is done in reverse * element order. */ + _GLIBCXX20_CONSTEXPR reverse_iterator rbegin() _GLIBCXX_NOEXCEPT { return reverse_iterator(end()); } @@ -852,6 +900,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * to the last element in the %vector. Iteration is done in * reverse element order. */ + _GLIBCXX20_CONSTEXPR const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(end()); } @@ -861,6 +910,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * before the first element in the %vector. Iteration is done * in reverse element order. */ + _GLIBCXX20_CONSTEXPR reverse_iterator rend() _GLIBCXX_NOEXCEPT { return reverse_iterator(begin()); } @@ -870,6 +920,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * to one before the first element in the %vector. Iteration * is done in reverse element order. */ + _GLIBCXX20_CONSTEXPR const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT { return const_reverse_iterator(begin()); } @@ -880,6 +931,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * first element in the %vector. Iteration is done in ordinary * element order. */ + _GLIBCXX20_CONSTEXPR const_iterator cbegin() const noexcept { return const_iterator(this->_M_impl._M_start); } @@ -889,6 +941,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * the last element in the %vector. Iteration is done in * ordinary element order. */ + _GLIBCXX20_CONSTEXPR const_iterator cend() const noexcept { return const_iterator(this->_M_impl._M_finish); } @@ -898,6 +951,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * to the last element in the %vector. Iteration is done in * reverse element order. */ + _GLIBCXX20_CONSTEXPR const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } @@ -907,6 +961,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * to one before the first element in the %vector. Iteration * is done in reverse element order. */ + _GLIBCXX20_CONSTEXPR const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } @@ -914,11 +969,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // [23.2.4.2] capacity /** Returns the number of elements in the %vector. */ + _GLIBCXX20_CONSTEXPR size_type size() const _GLIBCXX_NOEXCEPT { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); } /** Returns the size() of the largest possible %vector. */ + _GLIBCXX20_CONSTEXPR size_type max_size() const _GLIBCXX_NOEXCEPT { return _S_max_size(_M_get_Tp_allocator()); } @@ -933,6 +990,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * %vector's current size the %vector is truncated, otherwise * default constructed elements are appended. */ + _GLIBCXX20_CONSTEXPR void resize(size_type __new_size) { @@ -953,6 +1011,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * the %vector is extended and new elements are populated with * given data. */ + _GLIBCXX20_CONSTEXPR void resize(size_type __new_size, const value_type& __x) { @@ -973,6 +1032,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * the %vector is extended and new elements are populated with * given data. */ + _GLIBCXX20_CONSTEXPR void resize(size_type __new_size, value_type __x = value_type()) { @@ -985,6 +1045,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L /** A non-binding request to reduce capacity() to size(). */ + _GLIBCXX20_CONSTEXPR void shrink_to_fit() { _M_shrink_to_fit(); } @@ -994,6 +1055,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * Returns the total number of elements that the %vector can * hold before needing to allocate more memory. */ + _GLIBCXX20_CONSTEXPR size_type capacity() const _GLIBCXX_NOEXCEPT { return size_type(this->_M_impl._M_end_of_storage @@ -1003,6 +1065,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * Returns true if the %vector is empty. (Thus begin() would * equal end().) */ + _GLIBCXX20_CONSTEXPR _GLIBCXX_NODISCARD bool empty() const _GLIBCXX_NOEXCEPT { return begin() == end(); } @@ -1024,6 +1087,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * %advance, and thus prevent a possible reallocation of memory * and copying of %vector data. */ + _GLIBCXX20_CONSTEXPR void reserve(size_type __n); @@ -1039,6 +1103,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * out_of_range lookups are not defined. (For checked lookups * see at().) */ + _GLIBCXX20_CONSTEXPR reference operator[](size_type __n) _GLIBCXX_NOEXCEPT { @@ -1057,6 +1122,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * out_of_range lookups are not defined. (For checked lookups * see at().) */ + _GLIBCXX20_CONSTEXPR const_reference operator[](size_type __n) const _GLIBCXX_NOEXCEPT { @@ -1066,6 +1132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER protected: /// Safety check used only from at(). + _GLIBCXX20_CONSTEXPR void _M_range_check(size_type __n) const { @@ -1088,6 +1155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * is first checked that it is in the range of the vector. The * function throws out_of_range if the check fails. */ + _GLIBCXX20_CONSTEXPR reference at(size_type __n) { @@ -1106,6 +1174,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * is first checked that it is in the range of the vector. The * function throws out_of_range if the check fails. */ + _GLIBCXX20_CONSTEXPR const_reference at(size_type __n) const { @@ -1117,6 +1186,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * Returns a read/write reference to the data at the first * element of the %vector. */ + _GLIBCXX20_CONSTEXPR reference front() _GLIBCXX_NOEXCEPT { @@ -1128,6 +1198,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * Returns a read-only (constant) reference to the data at the first * element of the %vector. */ + _GLIBCXX20_CONSTEXPR const_reference front() const _GLIBCXX_NOEXCEPT { @@ -1139,6 +1210,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * Returns a read/write reference to the data at the last * element of the %vector. */ + _GLIBCXX20_CONSTEXPR reference back() _GLIBCXX_NOEXCEPT { @@ -1150,6 +1222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * Returns a read-only (constant) reference to the data at the * last element of the %vector. */ + _GLIBCXX20_CONSTEXPR const_reference back() const _GLIBCXX_NOEXCEPT { @@ -1164,10 +1237,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * Returns a pointer such that [data(), data() + size()) is a valid * range. For a non-empty %vector, data() == &front(). */ + _GLIBCXX20_CONSTEXPR _Tp* data() _GLIBCXX_NOEXCEPT { return _M_data_ptr(this->_M_impl._M_start); } + _GLIBCXX20_CONSTEXPR const _Tp* data() const _GLIBCXX_NOEXCEPT { return _M_data_ptr(this->_M_impl._M_start); } @@ -1183,6 +1258,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * done in constant time if the %vector has preallocated space * available. */ + _GLIBCXX20_CONSTEXPR void push_back(const value_type& __x) { @@ -1199,12 +1275,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR void push_back(value_type&& __x) { emplace_back(std::move(__x)); } template<typename... _Args> #if __cplusplus > 201402L + _GLIBCXX20_CONSTEXPR reference #else void @@ -1221,6 +1299,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * data is needed, it should be retrieved before pop_back() is * called. */ + _GLIBCXX20_CONSTEXPR void pop_back() _GLIBCXX_NOEXCEPT { @@ -1244,6 +1323,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * std::list. */ template<typename... _Args> + _GLIBCXX20_CONSTEXPR iterator emplace(const_iterator __position, _Args&&... __args) { return _M_emplace_aux(__position, std::forward<_Args>(__args)...); } @@ -1259,6 +1339,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * could be expensive for a %vector and if it is frequently * used the user should consider using std::list. */ + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __position, const value_type& __x); #else @@ -1289,6 +1370,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * could be expensive for a %vector and if it is frequently * used the user should consider using std::list. */ + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __position, value_type&& __x) { return _M_insert_rval(__position, std::move(__x)); } @@ -1306,6 +1388,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * %vector and if it is frequently used the user should * consider using std::list. */ + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __position, initializer_list<value_type> __l) { @@ -1331,6 +1414,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * %vector and if it is frequently used the user should * consider using std::list. */ + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __position, size_type __n, const value_type& __x) { @@ -1375,6 +1459,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ template<typename _InputIterator, typename = std::_RequireInputIter<_InputIterator>> + _GLIBCXX20_CONSTEXPR iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last) @@ -1400,6 +1485,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * consider using std::list. */ template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void insert(iterator __position, _InputIterator __first, _InputIterator __last) @@ -1425,6 +1511,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * the pointed-to memory is not touched in any way. Managing * the pointer is the user's responsibility. */ + _GLIBCXX20_CONSTEXPR iterator #if __cplusplus >= 201103L erase(const_iterator __position) @@ -1452,6 +1539,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * pointers, the pointed-to memory is not touched in any way. * Managing the pointer is the user's responsibility. */ + _GLIBCXX20_CONSTEXPR iterator #if __cplusplus >= 201103L erase(const_iterator __first, const_iterator __last) @@ -1476,6 +1564,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * * Whether the allocators are swapped depends on the allocator traits. */ + _GLIBCXX20_CONSTEXPR void swap(vector& __x) _GLIBCXX_NOEXCEPT { @@ -1494,6 +1583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * pointed-to memory is not touched in any way. Managing the pointer is * the user's responsibility. */ + _GLIBCXX20_CONSTEXPR void clear() _GLIBCXX_NOEXCEPT { _M_erase_at_end(this->_M_impl._M_start); } @@ -1504,6 +1594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * obtain @a n bytes of memory, and then copies [first,last) into it. */ template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, _ForwardIterator __last) @@ -1531,6 +1622,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 438. Ambiguity in the "do the right thing" clause template<typename _Integer> + _GLIBCXX20_CONSTEXPR void _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type) { @@ -1543,6 +1635,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the range constructor to implement [23.1.1]/9 template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) @@ -1554,6 +1647,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the second initialize_dispatch above template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) @@ -1573,6 +1667,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the second initialize_dispatch above template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) @@ -1589,6 +1684,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the first initialize_dispatch above and by the // vector(n,value,a) constructor. + _GLIBCXX20_CONSTEXPR void _M_fill_initialize(size_type __n, const value_type& __value) { @@ -1599,6 +1695,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L // Called by the vector(n) constructor. + _GLIBCXX20_CONSTEXPR void _M_default_initialize(size_type __n) { @@ -1616,12 +1713,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 438. Ambiguity in the "do the right thing" clause template<typename _Integer> + _GLIBCXX20_CONSTEXPR void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) { _M_fill_assign(__n, __val); } // Called by the range assign to implement [23.1.1]/9 template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type) @@ -1629,18 +1728,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the second assign_dispatch above template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag); // Called by the second assign_dispatch above template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); // Called by assign(n,t), and the range assign when it turns out // to be the same thing. + _GLIBCXX20_CONSTEXPR void _M_fill_assign(size_type __n, const value_type& __val); @@ -1651,6 +1753,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 438. Ambiguity in the "do the right thing" clause template<typename _Integer> + _GLIBCXX20_CONSTEXPR void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, __true_type) @@ -1658,6 +1761,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the range insert to implement [23.1.1]/9 template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_insert_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, __false_type) @@ -1668,26 +1772,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by the second insert_dispatch above template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void _M_range_insert(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag); // Called by the second insert_dispatch above template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void _M_range_insert(iterator __pos, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag); // Called by insert(p,n,x), and the range insert when it turns out to be // the same thing. + _GLIBCXX20_CONSTEXPR void _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); #if __cplusplus >= 201103L // Called by resize(n). + _GLIBCXX20_CONSTEXPR void _M_default_append(size_type __n); + _GLIBCXX20_CONSTEXPR bool _M_shrink_to_fit(); #endif @@ -1706,19 +1815,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { template<typename... _Args> explicit + _GLIBCXX20_CONSTEXPR _Temporary_value(vector* __vec, _Args&&... __args) : _M_this(__vec) { _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(), std::forward<_Args>(__args)...); } + _GLIBCXX20_CONSTEXPR ~_Temporary_value() { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); } + _GLIBCXX20_CONSTEXPR value_type& _M_val() { return *_M_ptr(); } private: + _GLIBCXX20_CONSTEXPR _Tp* _M_ptr() { return reinterpret_cast<_Tp*>(&__buf); } @@ -1729,29 +1842,35 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by insert(p,x) and other functions when insertion needs to // reallocate or move existing elements. _Arg is either _Tp& or _Tp. template<typename _Arg> + _GLIBCXX20_CONSTEXPR void _M_insert_aux(iterator __position, _Arg&& __arg); template<typename... _Args> + _GLIBCXX20_CONSTEXPR void _M_realloc_insert(iterator __position, _Args&&... __args); // Either move-construct at the end, or forward to _M_insert_aux. + _GLIBCXX20_CONSTEXPR iterator _M_insert_rval(const_iterator __position, value_type&& __v); // Try to emplace at the end, otherwise forward to _M_insert_aux. template<typename... _Args> + _GLIBCXX20_CONSTEXPR iterator _M_emplace_aux(const_iterator __position, _Args&&... __args); // Emplacing an rvalue of the correct type can use _M_insert_rval. + _GLIBCXX20_CONSTEXPR iterator _M_emplace_aux(const_iterator __position, value_type&& __v) { return _M_insert_rval(__position, std::move(__v)); } #endif // Called by _M_fill_insert, _M_insert_aux etc. + _GLIBCXX20_CONSTEXPR size_type _M_check_len(size_type __n, const char* __s) const { @@ -1763,7 +1882,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } // Called by constructors to check initial size. - static size_type + static _GLIBCXX20_CONSTEXPR size_type _S_check_init_len(size_type __n, const allocator_type& __a) { if (__n > _S_max_size(_Tp_alloc_type(__a))) @@ -1772,7 +1891,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __n; } - static size_type + static _GLIBCXX20_CONSTEXPR size_type _S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT { // std::distance(begin(), end()) cannot be greater than PTRDIFF_MAX, @@ -1788,6 +1907,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Called by erase(q1,q2), clear(), resize(), _M_fill_assign, // _M_assign_aux. + _GLIBCXX20_CONSTEXPR void _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT { @@ -1800,9 +1920,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } } + _GLIBCXX20_CONSTEXPR iterator _M_erase(iterator __position); + _GLIBCXX20_CONSTEXPR iterator _M_erase(iterator __first, iterator __last); @@ -1811,6 +1933,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Constant-time move assignment when source object's memory can be // moved, either because the source's allocator will move too // or because the allocators are equal. + _GLIBCXX20_CONSTEXPR void _M_move_assign(vector&& __x, true_type) noexcept { @@ -1822,6 +1945,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Do move assignment when it might not be possible to move source // object's memory, resulting in a linear-time operation. + _GLIBCXX20_CONSTEXPR void _M_move_assign(vector&& __x, false_type) { @@ -1840,12 +1964,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif template<typename _Up> + _GLIBCXX20_CONSTEXPR _Up* _M_data_ptr(_Up* __ptr) const _GLIBCXX_NOEXCEPT { return __ptr; } #if __cplusplus >= 201103L template<typename _Ptr> + _GLIBCXX20_CONSTEXPR typename std::pointer_traits<_Ptr>::element_type* _M_data_ptr(_Ptr __ptr) const { return empty() ? nullptr : std::__to_address(__ptr); } @@ -1888,7 +2014,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * and if corresponding elements compare equal. */ template<typename _Tp, typename _Alloc> - inline bool + inline _GLIBCXX20_CONSTEXPR bool operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return (__x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin())); } @@ -1906,7 +2032,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * `<` and `>=` etc. */ template<typename _Tp, typename _Alloc> - inline __detail::__synth3way_t<_Tp> + inline _GLIBCXX20_CONSTEXPR __detail::__synth3way_t<_Tp> operator<=>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return std::lexicographical_compare_three_way(__x.begin(), __x.end(), @@ -1926,39 +2052,39 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * See std::lexicographical_compare() for how the determination is made. */ template<typename _Tp, typename _Alloc> - inline bool + inline _GLIBCXX20_CONSTEXPR bool operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); } /// Based on operator== template<typename _Tp, typename _Alloc> - inline bool + inline _GLIBCXX20_CONSTEXPR bool operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__x == __y); } /// Based on operator< template<typename _Tp, typename _Alloc> - inline bool + inline _GLIBCXX20_CONSTEXPR bool operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return __y < __x; } /// Based on operator< template<typename _Tp, typename _Alloc> - inline bool + inline _GLIBCXX20_CONSTEXPR bool operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__y < __x); } /// Based on operator< template<typename _Tp, typename _Alloc> - inline bool + inline _GLIBCXX20_CONSTEXPR bool operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) { return !(__x < __y); } #endif // three-way comparison /// See std::vector::swap(). template<typename _Tp, typename _Alloc> - inline void + inline _GLIBCXX20_CONSTEXPR void swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) { __x.swap(__y); } diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 27e63388feb..6f2e3eaa21d 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -62,6 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: reserve(size_type __n) @@ -102,6 +103,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> template<typename... _Args> #if __cplusplus > 201402L + _GLIBCXX20_CONSTEXPR typename vector<_Tp, _Alloc>::reference #else void @@ -126,6 +128,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: #if __cplusplus >= 201103L @@ -167,6 +170,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: _M_erase(iterator __position) @@ -180,6 +184,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: _M_erase(iterator __first, iterator __last) @@ -194,6 +199,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR vector<_Tp, _Alloc>& vector<_Tp, _Alloc>:: operator=(const vector<_Tp, _Alloc>& __x) @@ -253,6 +259,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_fill_assign(size_t __n, const value_type& __val) @@ -278,6 +285,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_assign_aux(_InputIterator __first, _InputIterator __last, @@ -296,6 +304,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, @@ -336,6 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR auto vector<_Tp, _Alloc>:: _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator @@ -360,6 +370,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> template<typename... _Args> + _GLIBCXX20_CONSTEXPR auto vector<_Tp, _Alloc>:: _M_emplace_aux(const_iterator __position, _Args&&... __args) @@ -391,6 +402,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> template<typename _Arg> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_insert_aux(iterator __position, _Arg&& __arg) @@ -422,6 +434,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _Tp, typename _Alloc> template<typename... _Args> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_realloc_insert(iterator __position, _Args&&... __args) @@ -505,6 +518,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_fill_insert(iterator __position, size_type __n, const value_type& __x) @@ -607,6 +621,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_default_append(size_type __n) @@ -683,6 +698,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Tp, typename _Alloc> + _GLIBCXX20_CONSTEXPR bool vector<_Tp, _Alloc>:: _M_shrink_to_fit() @@ -696,6 +712,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> template<typename _InputIterator> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_range_insert(iterator __pos, _InputIterator __first, @@ -717,6 +734,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc> template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void vector<_Tp, _Alloc>:: _M_range_insert(iterator __position, _ForwardIterator __first, @@ -806,6 +824,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // vector<bool> template<typename _Alloc> + _GLIBCXX20_CONSTEXPR void vector<bool, _Alloc>:: _M_reallocate(size_type __n) @@ -820,6 +839,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Alloc> + _GLIBCXX20_CONSTEXPR void vector<bool, _Alloc>:: _M_fill_insert(iterator __position, size_type __n, bool __x) @@ -852,6 +872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Alloc> template<typename _ForwardIterator> + _GLIBCXX20_CONSTEXPR void vector<bool, _Alloc>:: _M_insert_range(iterator __position, _ForwardIterator __first, @@ -886,6 +907,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Alloc> + _GLIBCXX20_CONSTEXPR void vector<bool, _Alloc>:: _M_insert_aux(iterator __position, bool __x) @@ -914,6 +936,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Alloc> + _GLIBCXX20_CONSTEXPR typename vector<bool, _Alloc>::iterator vector<bool, _Alloc>:: _M_erase(iterator __position) @@ -925,6 +948,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<typename _Alloc> + _GLIBCXX20_CONSTEXPR typename vector<bool, _Alloc>::iterator vector<bool, _Alloc>:: _M_erase(iterator __first, iterator __last) @@ -936,6 +960,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<typename _Alloc> + _GLIBCXX20_CONSTEXPR bool vector<bool, _Alloc>:: _M_shrink_to_fit() @@ -963,6 +988,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Alloc> + _GLIBCXX20_CONSTEXPR size_t hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>:: operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const noexcept diff --git a/libstdc++-v3/include/debug/safe_iterator.tcc b/libstdc++-v3/include/debug/safe_iterator.tcc index f694e514239..c9b56c63c17 100644 --- a/libstdc++-v3/include/debug/safe_iterator.tcc +++ b/libstdc++-v3/include/debug/safe_iterator.tcc @@ -376,7 +376,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template<typename _Ite, typename _Seq, typename _Cat, typename _Tp> - void + _GLIBCXX20_CONSTEXPR void __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __last, const _Tp& __value) diff --git a/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc index 54f449e56cb..8dda2742718 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc @@ -25,58 +25,72 @@ namespace std { template <class T, class Allocator> class vector; template <class T, class Allocator> + _GLIBCXX20_CONSTEXPR bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y); template <class T, class Allocator> + _GLIBCXX20_CONSTEXPR bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y); template <class T, class Allocator> + _GLIBCXX20_CONSTEXPR bool operator!=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); template <class T, class Allocator> + _GLIBCXX20_CONSTEXPR bool operator> (const vector<T,Allocator>& x, const vector<T,Allocator>& y); template <class T, class Allocator> + _GLIBCXX20_CONSTEXPR bool operator>=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); template <class T, class Allocator> + _GLIBCXX20_CONSTEXPR bool operator<=(const vector<T,Allocator>& x, const vector<T,Allocator>& y); template <class T, class Allocator> + _GLIBCXX20_CONSTEXPR void swap(vector<T,Allocator>& x, vector<T,Allocator>& y); template <class Allocator> class vector<bool,Allocator>; template <class Allocator> + _GLIBCXX20_CONSTEXPR bool operator==(const vector<bool,Allocator>& x, const vector<bool,Allocator>& y); template <class Allocator> + _GLIBCXX20_CONSTEXPR bool operator< (const vector<bool,Allocator>& x, const vector<bool,Allocator>& y); template <class Allocator> + _GLIBCXX20_CONSTEXPR bool operator!=(const vector<bool,Allocator>& x, const vector<bool,Allocator>& y); template <class Allocator> + _GLIBCXX20_CONSTEXPR bool operator> (const vector<bool,Allocator>& x, const vector<bool,Allocator>& y); template <class Allocator> + _GLIBCXX20_CONSTEXPR bool operator>=(const vector<bool,Allocator>& x, const vector<bool,Allocator>& y); template <class Allocator> + _GLIBCXX20_CONSTEXPR bool operator<=(const vector<bool,Allocator>& x, const vector<bool,Allocator>& y); template <class Allocator> + _GLIBCXX20_CONSTEXPR void swap(vector<bool,Allocator>& x, vector<bool,Allocator>& y); } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/constructors.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/constructors.cc new file mode 100644 index 00000000000..27f458b9ec4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/constructors.cc @@ -0,0 +1,139 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } + +#include<cstddef> +#include<type_traits> +#include<vector> + +namespace constructor_group_one{ + constexpr std::vector<int> case_1; + static_assert(case_1.size() == 0); +} + + +void constructor_group_two(){ + constexpr std::vector<int> case_2_1(0, 1); + + static_assert(case_2_1.size() == 0); + + //* + constexpr std::vector<int> case_2_2(1, 2); + static_assert(case_2_2.size() == 1); + static_assert(case_2_2.at(0) == 2); + //*/ + //* + constexpr std::vector<int> case_2_3(2, 3); + static_assert(case_2_3.size() == 2); + static_assert(case_2_3.at(0) == 3); + static_assert(case_2_3.at(1) == 3); + + constexpr std::vector<int> case_2_4(5, 4); + static_assert(case_2_4.size() == 5); + static_assert(case_2_4.at(0) == 4); + static_assert(case_2_4.at(1) == 4); + static_assert(case_2_4.at(2) == 4); + static_assert(case_2_4.at(3) == 4); + //*/ +} + + +namespace constructor_group_three{ + /* + constexpr std::vector<int> case_3_1(0); + static_assert(case_3_1.size() == 0); + //*//* + constexpr std::vector<int> case_3_2(1); + static_assert(case_3_2.size() == 1); + //*//* + constexpr std::vector<int> case_3_3(2); + static_assert(case_3_3.size() == 2); + //*//* + constexpr std::vector<int> case_3_4(5); + static_assert(case_3_4.size() == 5); + //*///* +} + + +namespace constructor_group_four{ + /* + using constructor_group_two::case_2_1; + using constructor_group_two::case_2_2; + using constructor_group_two::case_2_3; + using constructor_group_two::case_2_4; + /* + constexpr std::vector<int> case_4_1(case_2_1.begin(), case_2_1.end()); + static_assert(case_4_1.size() == 0); + + constexpr std::vector<int> case_4_2(case_2_2.begin(), case_2_2.end()); + static_assert(case_4_2.size() == 1); + static_assert(case_4_2.at(0) == 2); + + constexpr std::vector<int> case_4_3(case_2_3.begin(), case_2_3.end()); + static_assert(case_4_3.size() == 2); + static_assert(case_4_3.at(0) == 3); + static_assert(case_4_3.at(1) == 3); + + constexpr std::vector<int> case_4_4(case_2_4.begin(), case_2_4.end()); + static_assert(case_4_4.size() == 5); + static_assert(case_4_4.at(0) == 4); + static_assert(case_4_4.at(1) == 4); + static_assert(case_4_4.at(2) == 4); + static_assert(case_4_4.at(3) == 4); + //*/ +} + + + +namespace constructor_group_five{ + /* + using constructor_group_two::case_2_1; + using constructor_group_two::case_2_2; + using constructor_group_two::case_2_3; + using constructor_group_two::case_2_4; + /* + constexpr std::vector<int> case_5_1(case_2_1); + static_assert(case_5_1.size() == 0); + + constexpr std::vector<int> case_5_2(case_2_2); + static_assert(case_5_2.size() == 1); + static_assert(case_5_2.at(0) == 2); + + constexpr std::vector<int> case_5_3(case_2_3); + static_assert(case_5_3.size() == 2); + static_assert(case_5_3.at(0) == 3); + static_assert(case_5_3.at(1) == 3); + + constexpr std::vector<int> case_5_4(case_2_4); + static_assert(case_5_4.size() == 4); + static_assert(case_5_4.at(0) == 4); + static_assert(case_5_4.at(1) == 4); + static_assert(case_5_4.at(2) == 4); + static_assert(case_5_4.at(3) == 4); + //*/ +} + + +namespace constructor_group_eight{ + /* + constexpr std::vector<int> case_8_1({}); + static_assert(case_8_1.size() == 0); + + constexpr std::vector<int> case_8_2({-1}); + static_assert(case_8_2.size() == 1); + static_assert(case_8_2.at(0) == -1); + + constexpr std::vector<int> case_8_3({-1, -2}); + static_assert(case_8_3.size() == 2); + static_assert(case_8_3.at(0) == -1); + static_assert(case_8_3.at(1) == -2); + + constexpr std::vector<int> case_8_4({-2, -1, 0, 1, 2}); + static_assert(case_8_4.size() == 5); + static_assert(case_8_4.at(0) == -2); + static_assert(case_8_4.at(1) == -1); + static_assert(case_8_4.at(2) == 0); + static_assert(case_8_4.at(3) == 1); + static_assert(case_8_4.at(4) == 2); + //*/ +} + diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/forward_iterators.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/forward_iterators.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/forward_iterators.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_assignment_operator.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_assignment_operator.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_assignment_operator.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_at.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_at.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_at.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_back.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_back.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_back.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_capacity.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_capacity.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_capacity.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_clear.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_clear.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_clear.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_data.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_data.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_data.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_emplace.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_emplace.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_emplace.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_emplace_back.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_emplace_back.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_emplace_back.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_empty.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_empty.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_empty.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_erase.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_erase.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_erase.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_front.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_front.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_front.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_index_access.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_index_access.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_index_access.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_insert.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_insert.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_insert.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_max_size.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_max_size.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_max_size.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_pop_back.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_pop_back.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_pop_back.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_push_back.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_push_back.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_push_back.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_reserve.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_reserve.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_reserve.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_resize.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_resize.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_resize.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_shrink_to_fit.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_shrink_to_fit.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_size.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_size.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_size.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_swap.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_swap.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/function_swap.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_difference_type.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_difference_type.cc new file mode 100644 index 00000000000..3e0b5b71542 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_difference_type.cc @@ -0,0 +1,9 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } +/* +#include<cstddef> +#include<type_traits> +#include<vector> + +static_assert(std::is_same<std::vector<int>::difference_type, size_t>::value); +*/ \ No newline at end of file diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_iterator.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_iterator.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_iterator.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_size_type.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_size_type.cc new file mode 100644 index 00000000000..091c964d9e3 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_size_type.cc @@ -0,0 +1,12 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } +/* +#include<cstddef> +#include<type_traits> +#include<vector> + + +static_assert(std::is_same<size_t, size_t>::value); + +static_assert(std::is_same<std::vector<int>::size_type, size_t>::value); +*/ \ No newline at end of file diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_value_type.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_value_type.cc new file mode 100644 index 00000000000..7bda8ad9264 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/member_value_type.cc @@ -0,0 +1,13 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } +/* +#include<type_traits> +#include<vector> + + +static_assert(std::is_same<int, int>::value); + +static_assert(std::is_same<std::vector<int>::value_type, int>::value); + +static_assert(!std::is_same<std::vector<char>::value_type, int>::value); +*/ \ No newline at end of file diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_equality.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_equality.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_equality.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_greater_than.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_greater_than.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_greater_than.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_greater_then_or_equal.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_greater_then_or_equal.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_greater_then_or_equal.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_inequality.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_inequality.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_inequality.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_less_than.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_less_than.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_less_than.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_less_then_or_equal.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_less_then_or_equal.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/operator_less_then_or_equal.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/reverse_iterators.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/reverse_iterators.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/reverse_iterators.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_element.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_element.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_element.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" } diff --git a/libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_vector.cc b/libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_vector.cc new file mode 100644 index 00000000000..80465074309 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/constexpr/swap_vector.cc @@ -0,0 +1,2 @@ +// { dg-do compile { target c++20 } } +// { dg-options "-std=c++20" }