... and container adaptors.
This adds the [[nodiscard]] attribute to functions with no side-effects
for the sequence containers and their iterators, and the debug versions
of those containers, and the container adaptors,
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/forward_list.h: Add [[nodiscard]] to functions
with no side-effects.
* include/bits/stl_bvector.h: Likewise.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/stl_queue.h: Likewise.
* include/bits/stl_stack.h: Likewise.
* include/bits/stl_vector.h: Likewise.
* include/debug/deque: Likewise.
* include/debug/forward_list: Likewise.
* include/debug/list: Likewise.
* include/debug/safe_iterator.h: Likewise.
* include/debug/vector: Likewise.
* include/std/array: Likewise.
* testsuite/23_containers/array/creation/3_neg.cc: Use
-Wno-unused-result.
* testsuite/23_containers/array/debug/back1_neg.cc: Cast result
to void.
* testsuite/23_containers/array/debug/back2_neg.cc: Likewise.
* testsuite/23_containers/array/debug/front1_neg.cc: Likewise.
* testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
* testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc:
Likewise.
* testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc:
Likewise.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.
* testsuite/23_containers/deque/cons/clear_allocator.cc: Cast
result to void.
* testsuite/23_containers/deque/debug/invalidation/4.cc:
Likewise.
* testsuite/23_containers/deque/types/1.cc: Use
-Wno-unused-result.
* testsuite/23_containers/list/types/1.cc: Cast result to void.
* testsuite/23_containers/priority_queue/members/7161.cc:
Likewise.
* testsuite/23_containers/queue/members/7157.cc: Likewise.
* testsuite/23_containers/vector/59829.cc: Likewise.
* testsuite/23_containers/vector/ext_pointer/types/1.cc:
Likewise.
* testsuite/23_containers/vector/ext_pointer/types/2.cc:
Likewise.
* testsuite/23_containers/vector/types/1.cc: Use
-Wno-unused-result.
_Fwd_list_iterator(_Fwd_list_node_base* __n) noexcept
: _M_node(__n) { }
+ [[__nodiscard__]]
reference
operator*() const noexcept
{ return *static_cast<_Node*>(this->_M_node)->_M_valptr(); }
+ [[__nodiscard__]]
pointer
operator->() const noexcept
{ return static_cast<_Node*>(this->_M_node)->_M_valptr(); }
/**
* @brief Forward list iterator equality comparison.
*/
+ [[__nodiscard__]]
friend bool
operator==(const _Self& __x, const _Self& __y) noexcept
{ return __x._M_node == __y._M_node; }
/**
* @brief Forward list iterator inequality comparison.
*/
+ [[__nodiscard__]]
friend bool
operator!=(const _Self& __x, const _Self& __y) noexcept
{ return __x._M_node != __y._M_node; }
_Fwd_list_const_iterator(const iterator& __iter) noexcept
: _M_node(__iter._M_node) { }
+ [[__nodiscard__]]
reference
operator*() const noexcept
{ return *static_cast<_Node*>(this->_M_node)->_M_valptr(); }
+ [[__nodiscard__]]
pointer
operator->() const noexcept
{ return static_cast<_Node*>(this->_M_node)->_M_valptr(); }
/**
* @brief Forward list const_iterator equality comparison.
*/
+ [[__nodiscard__]]
friend bool
operator==(const _Self& __x, const _Self& __y) noexcept
{ return __x._M_node == __y._M_node; }
/**
* @brief Forward list const_iterator inequality comparison.
*/
+ [[__nodiscard__]]
friend bool
operator!=(const _Self& __x, const _Self& __y) noexcept
{ return __x._M_node != __y._M_node; }
* Returns a read/write iterator that points before the first element
* in the %forward_list. Iteration is done in ordinary element order.
*/
+ [[__nodiscard__]]
iterator
before_begin() noexcept
{ return iterator(&this->_M_impl._M_head); }
* first element in the %forward_list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
before_begin() const noexcept
{ return const_iterator(&this->_M_impl._M_head); }
* Returns a read/write iterator that points to the first element
* in the %forward_list. Iteration is done in ordinary element order.
*/
+ [[__nodiscard__]]
iterator
begin() noexcept
{ return iterator(this->_M_impl._M_head._M_next); }
* element in the %forward_list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
begin() const noexcept
{ return const_iterator(this->_M_impl._M_head._M_next); }
* element in the %forward_list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
iterator
end() noexcept
{ return iterator(nullptr); }
* element in the %forward_list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
end() const noexcept
{ return const_iterator(nullptr); }
* first element in the %forward_list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return const_iterator(this->_M_impl._M_head._M_next); }
* first element in the %forward_list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
cbefore_begin() const noexcept
{ return const_iterator(&this->_M_impl._M_head); }
* the last element in the %forward_list. Iteration is done in
* ordinary element order.
*/
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return const_iterator(nullptr); }
* Returns true if the %forward_list is empty. (Thus begin() would
* equal end().)
*/
- _GLIBCXX_NODISCARD bool
+ [[__nodiscard__]]
+ bool
empty() const noexcept
{ return this->_M_impl._M_head._M_next == nullptr; }
/**
* Returns the largest possible number of elements of %forward_list.
*/
+ [[__nodiscard__]]
size_type
max_size() const noexcept
{ return _Node_alloc_traits::max_size(this->_M_get_Node_allocator()); }
* Returns a read/write reference to the data at the first
* element of the %forward_list.
*/
+ [[__nodiscard__]]
reference
front()
{
* Returns a read-only (constant) reference to the data at the first
* element of the %forward_list.
*/
+ [[__nodiscard__]]
const_reference
front() const
{
* if corresponding elements compare equal.
*/
template<typename _Tp, typename _Alloc>
+ [[__nodiscard__]]
bool
operator==(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly);
* `<` and `>=` etc.
*/
template<typename _Tp, typename _Alloc>
+ [[nodiscard]]
inline __detail::__synth3way_t<_Tp>
operator<=>(const forward_list<_Tp, _Alloc>& __x,
const forward_list<_Tp, _Alloc>& __y)
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Tp, typename _Alloc>
+ [[__nodiscard__]]
inline bool
operator<(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
/// Based on operator==
template<typename _Tp, typename _Alloc>
+ [[__nodiscard__]]
inline bool
operator!=(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ [[__nodiscard__]]
inline bool
operator>(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ [[__nodiscard__]]
inline bool
operator>=(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ [[__nodiscard__]]
inline bool
operator<=(const forward_list<_Tp, _Alloc>& __lx,
const forward_list<_Tp, _Alloc>& __ly)
_Bit_reference(const _Bit_reference&) = default;
#endif
+ _GLIBCXX_NODISCARD
operator bool() const _GLIBCXX_NOEXCEPT
{ return !!(*_M_p & _M_mask); }
operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT
{ return *this = bool(__x); }
+ _GLIBCXX_NODISCARD
bool
operator==(const _Bit_reference& __x) const
{ return bool(*this) == bool(__x); }
+ _GLIBCXX_NODISCARD
bool
operator<(const _Bit_reference& __x) const
{ return !bool(*this) && bool(__x); }
_M_offset = static_cast<unsigned int>(__n);
}
+ _GLIBCXX_NODISCARD
friend _GLIBCXX20_CONSTEXPR bool
operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{ return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset; }
#if __cpp_lib_three_way_comparison
+ [[nodiscard]]
friend constexpr strong_ordering
operator<=>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
noexcept
return __x._M_offset <=> __y._M_offset;
}
#else
+ _GLIBCXX_NODISCARD
friend bool
operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{
|| (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset);
}
+ _GLIBCXX_NODISCARD
friend bool
operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{ return !(__x == __y); }
+ _GLIBCXX_NODISCARD
friend bool
operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{ return __y < __x; }
+ _GLIBCXX_NODISCARD
friend bool
operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{ return !(__y < __x); }
+ _GLIBCXX_NODISCARD
friend bool
operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
{ return !(__x < __y); }
_M_const_cast() const
{ return *this; }
+ _GLIBCXX_NODISCARD
reference
operator*() const
{ return reference(_M_p, 1UL << _M_offset); }
return *this;
}
+ _GLIBCXX_NODISCARD
reference
operator[](difference_type __i) const
{ return *(*this + __i); }
+ _GLIBCXX_NODISCARD
friend iterator
operator+(const iterator& __x, difference_type __n)
{
return __tmp;
}
+ _GLIBCXX_NODISCARD
friend iterator
operator+(difference_type __n, const iterator& __x)
{ return __x + __n; }
+ _GLIBCXX_NODISCARD
friend iterator
operator-(const iterator& __x, difference_type __n)
{
_M_const_cast() const
{ return _Bit_iterator(_M_p, _M_offset); }
+ _GLIBCXX_NODISCARD
const_reference
operator*() const
{ return _Bit_reference(_M_p, 1UL << _M_offset); }
return *this;
}
+ _GLIBCXX_NODISCARD
const_reference
operator[](difference_type __i) const
{ return *(*this + __i); }
+ _GLIBCXX_NODISCARD
friend const_iterator
operator+(const const_iterator& __x, difference_type __n)
{
return __tmp;
}
+ _GLIBCXX_NODISCARD
friend const_iterator
operator-(const const_iterator& __x, difference_type __n)
{
return __tmp;
}
+ _GLIBCXX_NODISCARD
friend const_iterator
operator+(difference_type __n, const const_iterator& __x)
{ return __x + __n; }
{ _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); }
#endif
+ _GLIBCXX_NODISCARD
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_impl._M_start._M_p, 0); }
+ _GLIBCXX_NODISCARD
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_impl._M_start._M_p, 0); }
+ _GLIBCXX_NODISCARD
iterator
end() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
+ _GLIBCXX_NODISCARD
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
+ _GLIBCXX_NODISCARD
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return const_iterator(this->_M_impl._M_start._M_p, 0); }
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return this->_M_impl._M_finish; }
+ [[__nodiscard__]]
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
+ [[__nodiscard__]]
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
+ _GLIBCXX_NODISCARD
size_type
size() const _GLIBCXX_NOEXCEPT
{ return size_type(end() - begin()); }
+ _GLIBCXX_NODISCARD
size_type
max_size() const _GLIBCXX_NOEXCEPT
{
? __asize * int(_S_word_bit) : __isize);
}
+ _GLIBCXX_NODISCARD
size_type
capacity() const _GLIBCXX_NOEXCEPT
{ return size_type(const_iterator(this->_M_impl._M_end_addr(), 0)
empty() const _GLIBCXX_NOEXCEPT
{ return begin() == end(); }
+ _GLIBCXX_NODISCARD
reference
operator[](size_type __n)
{ return begin()[__n]; }
+ _GLIBCXX_NODISCARD
const_reference
operator[](size_type __n) const
{ return begin()[__n]; }
_M_reallocate(__n);
}
+ _GLIBCXX_NODISCARD
reference
front()
{ return *begin(); }
+ _GLIBCXX_NODISCARD
const_reference
front() const
{ return *begin(); }
+ _GLIBCXX_NODISCARD
reference
back()
{ return *(end() - 1); }
+ _GLIBCXX_NODISCARD
const_reference
back() const
{ return *(end() - 1); }
_M_const_cast() const _GLIBCXX_NOEXCEPT
{ return iterator(_M_cur, _M_node); }
+ _GLIBCXX_NODISCARD
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_cur; }
+ _GLIBCXX_NODISCARD
pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return _M_cur; }
operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
{ return *this += -__n; }
+ _GLIBCXX_NODISCARD
reference
operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{ return *(*this + __n); }
_M_last = _M_first + difference_type(_S_buffer_size());
}
+ _GLIBCXX_NODISCARD
friend bool
operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_cur == __y._M_cur; }
// order to avoid ambiguous overload resolution when std::rel_ops
// operators are in scope (for additional details, see libstdc++/3628)
template<typename _RefR, typename _PtrR>
+ _GLIBCXX_NODISCARD
friend bool
operator==(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
{ return __x._M_cur == __y._M_cur; }
#if __cpp_lib_three_way_comparison
+ [[nodiscard]]
friend strong_ordering
operator<=>(const _Self& __x, const _Self& __y) noexcept
{
return __x._M_cur <=> __y._M_cur;
}
#else
+ _GLIBCXX_NODISCARD
friend bool
operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return !(__x == __y); }
template<typename _RefR, typename _PtrR>
+ _GLIBCXX_NODISCARD
friend bool
operator!=(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
{ return !(__x == __y); }
+ _GLIBCXX_NODISCARD
friend bool
operator<(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{
}
template<typename _RefR, typename _PtrR>
+ _GLIBCXX_NODISCARD
friend bool
operator<(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node);
}
+ _GLIBCXX_NODISCARD
friend bool
operator>(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __y < __x; }
template<typename _RefR, typename _PtrR>
+ _GLIBCXX_NODISCARD
friend bool
operator>(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
{ return __y < __x; }
+ _GLIBCXX_NODISCARD
friend bool
operator<=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return !(__y < __x); }
template<typename _RefR, typename _PtrR>
+ _GLIBCXX_NODISCARD
friend bool
operator<=(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
{ return !(__y < __x); }
+ _GLIBCXX_NODISCARD
friend bool
operator>=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return !(__x < __y); }
template<typename _RefR, typename _PtrR>
+ _GLIBCXX_NODISCARD
friend bool
operator>=(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
{ return !(__x < __y); }
#endif // three-way comparison
+ _GLIBCXX_NODISCARD
friend difference_type
operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{
// operators but also operator- must accept mixed iterator/const_iterator
// parameters.
template<typename _RefR, typename _PtrR>
+ _GLIBCXX_NODISCARD
friend difference_type
operator-(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT
+ (__y._M_last - __y._M_cur);
}
+ _GLIBCXX_NODISCARD
friend _Self
operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
return __tmp;
}
+ _GLIBCXX_NODISCARD
friend _Self
operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
return __tmp;
}
+ _GLIBCXX_NODISCARD
friend _Self
operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT
{ return __x + __n; }
#endif
/// Get a copy of the memory allocation object.
+ _GLIBCXX_NODISCARD
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return _Base::get_allocator(); }
* Returns a read/write iterator that points to the first element in the
* %deque. Iteration is done in ordinary element order.
*/
+ _GLIBCXX_NODISCARD
iterator
begin() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
* Returns a read-only (constant) iterator that points to the first
* element in the %deque. Iteration is done in ordinary element order.
*/
+ _GLIBCXX_NODISCARD
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
* element in the %deque. Iteration is done in ordinary
* element order.
*/
+ _GLIBCXX_NODISCARD
iterator
end() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
* the last element in the %deque. Iteration is done in
* ordinary element order.
*/
+ _GLIBCXX_NODISCARD
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
* last element in the %deque. Iteration is done in reverse
* element order.
*/
+ _GLIBCXX_NODISCARD
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_finish); }
* to the last element in the %deque. Iteration is done in
* reverse element order.
*/
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_finish); }
* before the first element in the %deque. Iteration is done
* in reverse element order.
*/
+ _GLIBCXX_NODISCARD
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_start); }
* to one before the first element in the %deque. Iteration is
* done in reverse element order.
*/
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_start); }
* Returns a read-only (constant) iterator that points to the first
* element in the %deque. Iteration is done in ordinary element order.
*/
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return this->_M_impl._M_start; }
* the last element in the %deque. Iteration is done in
* ordinary element order.
*/
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return this->_M_impl._M_finish; }
* to the last element in the %deque. Iteration is done in
* reverse element order.
*/
+ [[__nodiscard__]]
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_finish); }
* to one before the first element in the %deque. Iteration is
* done in reverse element order.
*/
+ [[__nodiscard__]]
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_start); }
// [23.2.1.2] capacity
/** Returns the number of elements in the %deque. */
+ _GLIBCXX_NODISCARD
size_type
size() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish - this->_M_impl._M_start; }
/** Returns the size() of the largest possible %deque. */
+ _GLIBCXX_NODISCARD
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _S_max_size(_M_get_Tp_allocator()); }
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
+ _GLIBCXX_NODISCARD
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
+ _GLIBCXX_NODISCARD
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
* Returns a read/write reference to the data at the first
* element of the %deque.
*/
+ _GLIBCXX_NODISCARD
reference
front() _GLIBCXX_NOEXCEPT
{
* Returns a read-only (constant) reference to the data at the first
* element of the %deque.
*/
+ _GLIBCXX_NODISCARD
const_reference
front() const _GLIBCXX_NOEXCEPT
{
* Returns a read/write reference to the data at the last element of the
* %deque.
*/
+ _GLIBCXX_NODISCARD
reference
back() _GLIBCXX_NOEXCEPT
{
* Returns a read-only (constant) reference to the data at the last
* element of the %deque.
*/
+ _GLIBCXX_NODISCARD
const_reference
back() const _GLIBCXX_NOEXCEPT
{
* and if corresponding elements compare equal.
*/
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator==(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return __x.size() == __y.size()
* `<` and `>=` etc.
*/
template<typename _Tp, typename _Alloc>
+ [[nodiscard]]
inline __detail::__synth3way_t<_Tp>
operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return std::lexicographical_compare(__x.begin(), __x.end(),
/// Based on operator==
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator!=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator<=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator>=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return !(__x < __y); }
{ return *this; }
// Must downcast from _List_node_base to _List_node to get to value.
+ _GLIBCXX_NODISCARD
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *static_cast<_Node*>(_M_node)->_M_valptr(); }
+ _GLIBCXX_NODISCARD
pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Node*>(_M_node)->_M_valptr(); }
return __tmp;
}
+ _GLIBCXX_NODISCARD
friend bool
operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node == __y._M_node; }
#if __cpp_impl_three_way_comparison < 201907L
+ _GLIBCXX_NODISCARD
friend bool
operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; }
{ return iterator(const_cast<__detail::_List_node_base*>(_M_node)); }
// Must downcast from List_node_base to _List_node to get to value.
+ _GLIBCXX_NODISCARD
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *static_cast<_Node*>(_M_node)->_M_valptr(); }
+ _GLIBCXX_NODISCARD
pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Node*>(_M_node)->_M_valptr(); }
return __tmp;
}
+ _GLIBCXX_NODISCARD
friend bool
operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node == __y._M_node; }
#if __cpp_impl_three_way_comparison < 201907L
+ _GLIBCXX_NODISCARD
friend bool
operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; }
* Returns a read/write iterator that points to the first element in the
* %list. Iteration is done in ordinary element order.
*/
+ _GLIBCXX_NODISCARD
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_impl._M_node._M_next); }
* first element in the %list. Iteration is done in ordinary
* element order.
*/
+ _GLIBCXX_NODISCARD
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_impl._M_node._M_next); }
* element in the %list. Iteration is done in ordinary element
* order.
*/
+ _GLIBCXX_NODISCARD
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(&this->_M_impl._M_node); }
* the last element in the %list. Iteration is done in ordinary
* element order.
*/
+ _GLIBCXX_NODISCARD
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(&this->_M_impl._M_node); }
* element in the %list. Iteration is done in reverse element
* order.
*/
+ _GLIBCXX_NODISCARD
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
* the last element in the %list. Iteration is done in reverse
* element order.
*/
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
* before the first element in the %list. Iteration is done in
* reverse element order.
*/
+ _GLIBCXX_NODISCARD
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
* before the first element in the %list. Iteration is done in reverse
* element order.
*/
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
* first element in the %list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return const_iterator(this->_M_impl._M_node._M_next); }
* the last element in the %list. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return const_iterator(&this->_M_impl._M_node); }
* the last element in the %list. Iteration is done in reverse
* element order.
*/
+ [[__nodiscard__]]
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
* before the first element in the %list. Iteration is done in reverse
* element order.
*/
+ [[__nodiscard__]]
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
{ return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
/** Returns the number of elements in the %list. */
+ _GLIBCXX_NODISCARD
size_type
size() const _GLIBCXX_NOEXCEPT
{ return _M_node_count(); }
/** Returns the size() of the largest possible %list. */
+ _GLIBCXX_NODISCARD
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _Node_alloc_traits::max_size(_M_get_Node_allocator()); }
* Returns a read/write reference to the data at the first
* element of the %list.
*/
+ _GLIBCXX_NODISCARD
reference
front() _GLIBCXX_NOEXCEPT
{ return *begin(); }
* Returns a read-only (constant) reference to the data at the first
* element of the %list.
*/
+ _GLIBCXX_NODISCARD
const_reference
front() const _GLIBCXX_NOEXCEPT
{ return *begin(); }
* Returns a read/write reference to the data at the last element
* of the %list.
*/
+ _GLIBCXX_NODISCARD
reference
back() _GLIBCXX_NOEXCEPT
{
* Returns a read-only (constant) reference to the data at the last
* element of the %list.
*/
+ _GLIBCXX_NODISCARD
const_reference
back() const _GLIBCXX_NOEXCEPT
{
* equal, and if corresponding elements compare equal.
*/
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{
* `<` and `>=` etc.
*/
template<typename _Tp, typename _Alloc>
+ [[nodiscard]]
inline __detail::__synth3way_t<_Tp>
operator<=>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{
* See std::lexicographical_compare() for how the determination is made.
*/
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return std::lexicographical_compare(__x.begin(), __x.end(),
/// Based on operator==
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Alloc>
+ _GLIBCXX_NODISCARD
inline bool
operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
{ return !(__x < __y); }
#endif
template<typename _Tp1, typename _Seq1>
+ _GLIBCXX_NODISCARD
friend bool
operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
+ _GLIBCXX_NODISCARD
friend bool
operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#if __cpp_lib_three_way_comparison
template<typename _Tp1, three_way_comparable _Seq1>
+ [[nodiscard]]
friend compare_three_way_result_t<_Seq1>
operator<=>(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#endif
{ return c.empty(); }
/** Returns the number of elements in the %queue. */
+ _GLIBCXX_NODISCARD
size_type
size() const
{ return c.size(); }
* Returns a read/write reference to the data at the first
* element of the %queue.
*/
+ _GLIBCXX_NODISCARD
reference
front()
{
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
+ _GLIBCXX_NODISCARD
const_reference
front() const
{
* Returns a read/write reference to the data at the last
* element of the %queue.
*/
+ _GLIBCXX_NODISCARD
reference
back()
{
* Returns a read-only (constant) reference to the data at the last
* element of the %queue.
*/
+ _GLIBCXX_NODISCARD
const_reference
back() const
{
* if their sequences compare equal.
*/
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c == __y.c; }
* determination.
*/
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x < __y); }
#if __cpp_lib_three_way_comparison
template<typename _Tp, three_way_comparable _Seq>
+ [[nodiscard]]
inline compare_three_way_result_t<_Seq>
operator<=>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c <=> __y.c; }
{ return c.empty(); }
/** Returns the number of elements in the %queue. */
+ _GLIBCXX_NODISCARD
size_type
size() const
{ return c.size(); }
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
+ _GLIBCXX_NODISCARD
const_reference
top() const
{
{ return c.empty(); }
/** Returns the number of elements in the %stack. */
+ _GLIBCXX_NODISCARD
size_type
size() const
{ return c.size(); }
* Returns a read/write reference to the data at the first
* element of the %stack.
*/
+ _GLIBCXX_NODISCARD
reference
top()
{
* Returns a read-only (constant) reference to the data at the first
* element of the %stack.
*/
+ _GLIBCXX_NODISCARD
const_reference
top() const
{
* equal.
*/
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return __x.c == __y.c; }
* determination.
*/
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Seq>
+ _GLIBCXX_NODISCARD
inline bool
operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return !(__x < __y); }
#if __cpp_lib_three_way_comparison
template<typename _Tp, three_way_comparable _Seq>
+ [[nodiscard]]
inline compare_three_way_result_t<_Seq>
operator<=>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
{ return __x.c <=> __y.c; }
* element in the %vector. Iteration is done in ordinary
* element order.
*/
+ _GLIBCXX_NODISCARD
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_impl._M_start); }
* first element in the %vector. Iteration is done in ordinary
* element order.
*/
+ _GLIBCXX_NODISCARD
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_impl._M_start); }
* element in the %vector. Iteration is done in ordinary
* element order.
*/
+ _GLIBCXX_NODISCARD
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(this->_M_impl._M_finish); }
* the last element in the %vector. Iteration is done in
* ordinary element order.
*/
+ _GLIBCXX_NODISCARD
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(this->_M_impl._M_finish); }
* last element in the %vector. Iteration is done in reverse
* element order.
*/
+ _GLIBCXX_NODISCARD
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
* to the last element in the %vector. Iteration is done in
* reverse element order.
*/
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
* before the first element in the %vector. Iteration is done
* in reverse element order.
*/
+ _GLIBCXX_NODISCARD
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
* to one before the first element in the %vector. Iteration
* is done in reverse element order.
*/
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
* first element in the %vector. Iteration is done in ordinary
* element order.
*/
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return const_iterator(this->_M_impl._M_start); }
* the last element in the %vector. Iteration is done in
* ordinary element order.
*/
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return const_iterator(this->_M_impl._M_finish); }
* to the last element in the %vector. Iteration is done in
* reverse element order.
*/
+ [[__nodiscard__]]
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
* to one before the first element in the %vector. Iteration
* is done in reverse element order.
*/
+ [[__nodiscard__]]
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
// [23.2.4.2] capacity
/** Returns the number of elements in the %vector. */
+ _GLIBCXX_NODISCARD
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. */
+ _GLIBCXX_NODISCARD
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _S_max_size(_M_get_Tp_allocator()); }
* Returns the total number of elements that the %vector can
* hold before needing to allocate more memory.
*/
+ _GLIBCXX_NODISCARD
size_type
capacity() const _GLIBCXX_NOEXCEPT
{ return size_type(this->_M_impl._M_end_of_storage
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
+ _GLIBCXX_NODISCARD
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
* out_of_range lookups are not defined. (For checked lookups
* see at().)
*/
+ _GLIBCXX_NODISCARD
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
* Returns a read/write reference to the data at the first
* element of the %vector.
*/
+ _GLIBCXX_NODISCARD
reference
front() _GLIBCXX_NOEXCEPT
{
* Returns a read-only (constant) reference to the data at the first
* element of the %vector.
*/
+ _GLIBCXX_NODISCARD
const_reference
front() const _GLIBCXX_NOEXCEPT
{
* Returns a read/write reference to the data at the last
* element of the %vector.
*/
+ _GLIBCXX_NODISCARD
reference
back() _GLIBCXX_NOEXCEPT
{
* Returns a read-only (constant) reference to the data at the
* last element of the %vector.
*/
+ _GLIBCXX_NODISCARD
const_reference
back() const _GLIBCXX_NOEXCEPT
{
* Returns a pointer such that [data(), data() + size()) is a valid
* range. For a non-empty %vector, data() == &front().
*/
+ _GLIBCXX_NODISCARD
_Tp*
data() _GLIBCXX_NOEXCEPT
{ return _M_data_ptr(this->_M_impl._M_start); }
+ _GLIBCXX_NODISCARD
const _Tp*
data() const _GLIBCXX_NOEXCEPT
{ return _M_data_ptr(this->_M_impl._M_start); }
using _Base::get_allocator;
// iterators:
+ _GLIBCXX_NODISCARD
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
+ _GLIBCXX_NODISCARD
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
+ _GLIBCXX_NODISCARD
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
+ _GLIBCXX_NODISCARD
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
+ _GLIBCXX_NODISCARD
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); }
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return const_iterator(_Base::end(), this); }
+ [[__nodiscard__]]
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
+ [[__nodiscard__]]
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
using _Base::empty;
// element access:
+ _GLIBCXX_NODISCARD
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
return _M_base()[__n];
}
+ _GLIBCXX_NODISCARD
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
using _Base::at;
+ _GLIBCXX_NODISCARD
reference
front() _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
+ _GLIBCXX_NODISCARD
const_reference
front() const _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
+ _GLIBCXX_NODISCARD
reference
back() _GLIBCXX_NOEXCEPT
{
return _Base::back();
}
+ _GLIBCXX_NODISCARD
const_reference
back() const _GLIBCXX_NOEXCEPT
{
// iterators:
+ [[__nodiscard__]]
iterator
before_begin() noexcept
{ return { _Base::before_begin(), this }; }
+ [[__nodiscard__]]
const_iterator
before_begin() const noexcept
{ return { _Base::before_begin(), this }; }
+ [[__nodiscard__]]
iterator
begin() noexcept
{ return { _Base::begin(), this }; }
+ [[__nodiscard__]]
const_iterator
begin() const noexcept
{ return { _Base::begin(), this }; }
+ [[__nodiscard__]]
iterator
end() noexcept
{ return { _Base::end(), this }; }
+ [[__nodiscard__]]
const_iterator
end() const noexcept
{ return { _Base::end(), this }; }
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return { _Base::cbegin(), this }; }
+ [[__nodiscard__]]
const_iterator
cbefore_begin() const noexcept
{ return { _Base::cbefore_begin(), this }; }
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return { _Base::cend(), this }; }
// element access:
+ [[__nodiscard__]]
reference
front()
{
return _Base::front();
}
+ [[__nodiscard__]]
const_reference
front() const
{
using _Base::get_allocator;
// iterators:
+ _GLIBCXX_NODISCARD
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
+ _GLIBCXX_NODISCARD
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
+ _GLIBCXX_NODISCARD
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
+ _GLIBCXX_NODISCARD
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
+ _GLIBCXX_NODISCARD
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); }
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return const_iterator(_Base::end(), this); }
+ [[__nodiscard__]]
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
+ [[__nodiscard__]]
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
// element access:
+ _GLIBCXX_NODISCARD
reference
front() _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
+ _GLIBCXX_NODISCARD
const_reference
front() const _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
+ _GLIBCXX_NODISCARD
reference
back() _GLIBCXX_NOEXCEPT
{
return _Base::back();
}
+ _GLIBCXX_NODISCARD
const_reference
back() const _GLIBCXX_NOEXCEPT
{
* @brief Iterator dereference.
* @pre iterator is dereferenceable
*/
+ _GLIBCXX_NODISCARD
reference
operator*() const _GLIBCXX_NOEXCEPT
{
* @brief Iterator dereference.
* @pre iterator is dereferenceable
*/
+ _GLIBCXX_NODISCARD
pointer
operator->() const _GLIBCXX_NOEXCEPT
{
typedef _Safe_iterator<_Iterator, _Sequence, iterator_category> _Self;
+ _GLIBCXX_NODISCARD
friend bool
operator==(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
{
}
template<typename _IteR>
+ _GLIBCXX_NODISCARD
friend bool
operator==(const _Self& __lhs,
const _Safe_iterator<_IteR, _Sequence, iterator_category>& __rhs)
}
#if ! __cpp_lib_three_way_comparison
+ _GLIBCXX_NODISCARD
friend bool
operator!=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
{
}
template<typename _IteR>
+ _GLIBCXX_NODISCARD
friend bool
operator!=(const _Self& __lhs,
const _Safe_iterator<_IteR, _Sequence, iterator_category>& __rhs)
}
// ------ Random access iterator requirements ------
+ _GLIBCXX_NODISCARD
reference
operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{
}
#if __cpp_lib_three_way_comparison
+ [[nodiscard]]
friend auto
operator<=>(const _Self& __lhs, const _Self& __rhs) noexcept
{
return __lhs.base() <=> __rhs.base();
}
+ [[nodiscard]]
friend auto
operator<=>(const _Self& __lhs, const _OtherSelf& __rhs) noexcept
{
return __lhs.base() <=> __rhs.base();
}
#else
+ _GLIBCXX_NODISCARD
friend bool
operator<(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() < __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend bool
operator<(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() < __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend bool
operator<=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() <= __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend bool
operator<=(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() <= __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend bool
operator>(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() > __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend bool
operator>(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() > __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend bool
operator>=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() >= __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend bool
operator>=(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
{
// According to the resolution of DR179 not only the various comparison
// operators but also operator- must accept mixed iterator/const_iterator
// parameters.
+ _GLIBCXX_NODISCARD
friend difference_type
operator-(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() - __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend difference_type
operator-(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT
{
return __lhs.base() - __rhs.base();
}
+ _GLIBCXX_NODISCARD
friend _Self
operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
return _Safe_iterator(__x.base() + __n, __x._M_sequence);
}
+ _GLIBCXX_NODISCARD
friend _Self
operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT
{
return _Safe_iterator(__n + __x.base(), __x._M_sequence);
}
+ _GLIBCXX_NODISCARD
friend _Self
operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
using _Base::get_allocator;
// iterators:
+ _GLIBCXX_NODISCARD
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
+ _GLIBCXX_NODISCARD
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
+ _GLIBCXX_NODISCARD
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
+ _GLIBCXX_NODISCARD
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
+ _GLIBCXX_NODISCARD
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
+ _GLIBCXX_NODISCARD
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
+ _GLIBCXX_NODISCARD
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
+ [[__nodiscard__]]
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); }
+ [[__nodiscard__]]
const_iterator
cend() const noexcept
{ return const_iterator(_Base::end(), this); }
+ [[__nodiscard__]]
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
+ [[__nodiscard__]]
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
}
#endif
+ _GLIBCXX_NODISCARD
size_type
capacity() const _GLIBCXX_NOEXCEPT
{
}
// element access:
+ _GLIBCXX_NODISCARD
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
return _M_base()[__n];
}
+ _GLIBCXX_NODISCARD
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
using _Base::at;
+ _GLIBCXX_NODISCARD
reference
front() _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
+ _GLIBCXX_NODISCARD
const_reference
front() const _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
+ _GLIBCXX_NODISCARD
reference
back() _GLIBCXX_NOEXCEPT
{
return _Base::back();
}
+ _GLIBCXX_NODISCARD
const_reference
back() const _GLIBCXX_NOEXCEPT
{
{ std::swap_ranges(begin(), end(), __other.begin()); }
// Iterators.
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR iterator
begin() noexcept
{ return iterator(data()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_iterator
begin() const noexcept
{ return const_iterator(data()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR iterator
end() noexcept
{ return iterator(data() + _Nm); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_iterator
end() const noexcept
{ return const_iterator(data() + _Nm); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR reverse_iterator
rbegin() noexcept
{ return reverse_iterator(end()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_reverse_iterator
rbegin() const noexcept
{ return const_reverse_iterator(end()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR reverse_iterator
rend() noexcept
{ return reverse_iterator(begin()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_reverse_iterator
rend() const noexcept
{ return const_reverse_iterator(begin()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_iterator
cbegin() const noexcept
{ return const_iterator(data()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_iterator
cend() const noexcept
{ return const_iterator(data() + _Nm); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
// Capacity.
+ [[__nodiscard__]]
constexpr size_type
size() const noexcept { return _Nm; }
+ [[__nodiscard__]]
constexpr size_type
max_size() const noexcept { return _Nm; }
- _GLIBCXX_NODISCARD constexpr bool
+ [[__nodiscard__]]
+ constexpr bool
empty() const noexcept { return size() == 0; }
// Element access.
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR reference
operator[](size_type __n) noexcept
{
return _AT_Type::_S_ref(_M_elems, __n);
}
+ [[__nodiscard__]]
constexpr const_reference
operator[](size_type __n) const noexcept
{
_AT_Type::_S_ref(_M_elems, 0));
}
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR reference
front() noexcept
{
return *begin();
}
+ [[__nodiscard__]]
constexpr const_reference
front() const noexcept
{
return _AT_Type::_S_ref(_M_elems, 0);
}
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR reference
back() noexcept
{
return _Nm ? *(end() - 1) : *end();
}
+ [[__nodiscard__]]
constexpr const_reference
back() const noexcept
{
: _AT_Type::_S_ref(_M_elems, 0);
}
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR pointer
data() noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
+ [[__nodiscard__]]
_GLIBCXX17_CONSTEXPR const_pointer
data() const noexcept
{ return _AT_Type::_S_ptr(_M_elems); }
// Array comparisons.
template<typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
_GLIBCXX20_CONSTEXPR
inline bool
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
#if __cpp_lib_three_way_comparison && __cpp_lib_concepts
template<typename _Tp, size_t _Nm>
+ [[nodiscard]]
constexpr __detail::__synth3way_t<_Tp>
operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
{
}
#else
template<typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
_GLIBCXX20_CONSTEXPR
inline bool
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one == __two); }
template<typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
_GLIBCXX20_CONSTEXPR
inline bool
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
}
template<typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
_GLIBCXX20_CONSTEXPR
inline bool
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return __two < __one; }
template<typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
_GLIBCXX20_CONSTEXPR
inline bool
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one > __two); }
template<typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
_GLIBCXX20_CONSTEXPR
inline bool
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
#endif
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
constexpr _Tp&
get(array<_Tp, _Nm>& __arr) noexcept
{
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
constexpr _Tp&&
get(array<_Tp, _Nm>&& __arr) noexcept
{
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
constexpr const _Tp&
get(const array<_Tp, _Nm>& __arr) noexcept
{
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ [[__nodiscard__]]
constexpr const _Tp&&
get(const array<_Tp, _Nm>&& __arr) noexcept
{
}
template<typename _Tp, size_t _Nm>
+ [[nodiscard]]
constexpr array<remove_cv_t<_Tp>, _Nm>
to_array(_Tp (&__a)[_Nm])
noexcept(is_nothrow_constructible_v<_Tp, _Tp&>)
}
template<typename _Tp, size_t _Nm>
+ [[nodiscard]]
constexpr array<remove_cv_t<_Tp>, _Nm>
to_array(_Tp (&&__a)[_Nm])
noexcept(is_nothrow_move_constructible_v<_Tp>)
-// { dg-options "-std=gnu++2a" }
+// { dg-options "-std=gnu++2a -Wno-unused-result" }
// { dg-do compile { target c++2a } }
// Copyright (C) 2019-2021 Free Software Foundation, Inc.
void test01()
{
std::array<int, 0> a;
- a.back();
+ (void) a.back();
}
int main()
void test01()
{
constexpr std::array<int, 0> a;
- a.back();
+ (void) a.back();
}
int main()
void test01()
{
std::array<int, 0> a;
- a.front();
+ (void) a.front();
}
int main()
void test01()
{
constexpr std::array<int, 0> a;
- a.front();
+ (void) a.front();
}
int main()
void test01()
{
std::array<int, 0> a;
- a[0];
+ (void) a[0];
}
int main()
void test01()
{
constexpr std::array<int, 0> a;
- a[0];
+ (void) a[0];
}
int main()
int n2 = std::get<1>(std::move(a));
int n3 = std::get<1>(ca);
-// { dg-error "static assertion failed" "" { target *-*-* } 367 }
-// { dg-error "static assertion failed" "" { target *-*-* } 375 }
-// { dg-error "static assertion failed" "" { target *-*-* } 383 }
+// { dg-error "static assertion failed" "" { target *-*-* } 398 }
+// { dg-error "static assertion failed" "" { target *-*-* } 407 }
+// { dg-error "static assertion failed" "" { target *-*-* } 416 }
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
-
+
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-
+
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
using __gnu_cxx::new_allocator;
template<typename T>
- class clear_alloc : public new_allocator<T>
+ class clear_alloc : public new_allocator<T>
{
public:
template <typename T1>
- struct rebind
+ struct rebind
{ typedef clear_alloc<T1> other; };
virtual void clear() throw()
clear_alloc() throw()
{ }
-
- clear_alloc(clear_alloc const&) throw() : new_allocator<T>()
+
+ clear_alloc(clear_alloc const&) throw() : new_allocator<T>()
{ }
-
+
template<typename T1>
clear_alloc(clear_alloc<T1> const&) throw()
{ }
this->clear();
return new_allocator<T>::allocate(n, hint);
}
-
+
void deallocate(T *ptr, typename new_allocator<T>::size_type n)
{
this->clear();
{
Container* pic = new Container;
int x = 230;
-
+
while (x--)
{
pic->push_back(x);
}
-
- pic->get_allocator();
-
+
+ (void) pic->get_allocator();
+
// The following has led to infinite recursions or cores.
pic->clear();
before = v.begin();
at = before + 3;
v.erase(at, v.end());
- *before;
+ (void) *before;
// clear()
before = v.begin();
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
+// { dg-options "-Wno-unused-result" }
#include <deque>
#include <testsuite_greedy_ops.h>
std::list<greedy_ops::X> l;
const std::list<greedy_ops::X> cl;
- l.size();
+ (void) l.size();
l.insert(l.begin(), greedy_ops::X());
l.insert(l.begin(), 1, greedy_ops::X());
l.insert(l.begin(), cl.begin(), cl.end());
for (int i = 0; i < 3; ++i)
pq.push(data[i]);
- pq.top();
+ (void) pq.top();
for (int i = 0; i < 2; ++i)
pq.pop();
std::queue<int> q;
q.push(1);
- q.front();
+ (void) q.front();
q.pop();
}
int main()
{
std::vector<int, Alloc<int>> a;
- a.data();
+ (void) a.data();
}
std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5);
const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1);
- v[0];
- w[0];
- v.size();
- v.capacity();
+ (void) v[0];
+ (void) w[0];
+ (void) v.size();
+ (void) v.capacity();
v.resize(1);
v.insert(v.begin(), N::X());
v.insert(v.begin(), 1, N::X());
std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > v(5);
const std::vector<N::X, __gnu_cxx::_ExtPtr_allocator<N::X> > w(1);
- v[0];
- w[0];
- v.size();
- v.capacity();
+ (void) v[0];
+ (void) w[0];
+ (void) v.size();
+ (void) v.capacity();
v.resize(1);
v.insert(v.begin(), N::X());
v.insert(v.begin(), 1, N::X());
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
+// { dg-options "-Wno-unused-result" }
#include <vector>
#include <testsuite_greedy_ops.h>