// <forward_list.tcc> -*- C++ -*-
-// Copyright (C) 2008-2018 Free Software Foundation, Inc.
+// Copyright (C) 2008-2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
return iterator(const_cast<_Node_base*>(__pos._M_node));
}
+#if __cplusplus > 201703L
+# define _GLIBCXX20_ONLY(__expr) __expr
+#else
+# define _GLIBCXX20_ONLY(__expr)
+#endif
+
template<typename _Tp, typename _Alloc>
- void
+ auto
forward_list<_Tp, _Alloc>::
- remove(const _Tp& __val)
+ remove(const _Tp& __val) -> __remove_return_type
{
+ size_type __removed __attribute__((__unused__)) = 0;
_Node_base* __curr = &this->_M_impl._M_head;
_Node_base* __extra = nullptr;
if (__tmp->_M_valptr() != std::__addressof(__val))
{
this->_M_erase_after(__curr);
+ _GLIBCXX20_ONLY( __removed++ );
continue;
}
else
}
if (__extra)
- this->_M_erase_after(__extra);
+ {
+ this->_M_erase_after(__extra);
+ _GLIBCXX20_ONLY( __removed++ );
+ }
+ return _GLIBCXX20_ONLY( __removed );
}
template<typename _Tp, typename _Alloc>
template<typename _Pred>
- void
+ auto
forward_list<_Tp, _Alloc>::
- remove_if(_Pred __pred)
+ remove_if(_Pred __pred) -> __remove_return_type
{
+ size_type __removed __attribute__((__unused__)) = 0;
_Node_base* __curr = &this->_M_impl._M_head;
while (_Node* __tmp = static_cast<_Node*>(__curr->_M_next))
{
if (__pred(*__tmp->_M_valptr()))
- this->_M_erase_after(__curr);
+ {
+ this->_M_erase_after(__curr);
+ _GLIBCXX20_ONLY( __removed++ );
+ }
else
__curr = __curr->_M_next;
}
+ return _GLIBCXX20_ONLY( __removed );
}
template<typename _Tp, typename _Alloc>
template<typename _BinPred>
- void
+ auto
forward_list<_Tp, _Alloc>::
- unique(_BinPred __binary_pred)
+ unique(_BinPred __binary_pred) -> __remove_return_type
{
iterator __first = begin();
iterator __last = end();
if (__first == __last)
- return;
+ return _GLIBCXX20_ONLY(0);
+ size_type __removed __attribute__((__unused__)) = 0;
iterator __next = __first;
while (++__next != __last)
{
if (__binary_pred(*__first, *__next))
- erase_after(__first);
+ {
+ erase_after(__first);
+ _GLIBCXX20_ONLY( __removed++ );
+ }
else
__first = __next;
__next = __first;
}
+ return _GLIBCXX20_ONLY( __removed );
}
+#undef _GLIBCXX20_ONLY
+
template<typename _Tp, typename _Alloc>
template<typename _Comp>
void
auto __iy = __ly.cbegin();
while (__ix != __lx.cend() && __iy != __ly.cend())
{
- if (*__ix != *__iy)
+ if (!(*__ix == *__iy))
return false;
++__ix;
++__iy;
__p = static_cast<_Node*>(__p->_M_next);
--__psize;
}
- else if (__comp(*__p->_M_valptr(), *__q->_M_valptr()))
+ else if (!__comp(*__q->_M_valptr(), *__p->_M_valptr()))
{
- // First node of p is lower; e must come from p.
+ // First node of q is not lower; e must come from p.
__e = __p;
__p = static_cast<_Node*>(__p->_M_next);
--__psize;