2016-09-25 François Dumont <fdumont@gcc.gnu.org>
+ * include/debug/bitset (bitset::reference::reference(const _Base_ref&,
+ bitset*)): Remove __unused__ attribute.
+ * include/debug/safe_base.h (_Safe_iterator_base): Make
+ _Safe_sequence_base a friend.
+ (_Safe_iterator_base::_M_attach): Make protected.
+ (_Safe_iterator_base::_M_attach_single): Likewise.
+ (_Safe_iterator_base::_M_detach): Likewise.
+ (_Safe_iterator_base::_M_detach_single): Likewise.
+ (_Safe_sequence_base): Make _Safe_iterator_base a friend.
+ (_Safe_sequence_base::_Safe_sequence_base(_Safe_sequence_base&&)): New.
+ (_Safe_sequence_base::_M_swap): Make protected.
+ (_Safe_sequence_base::_M_attach): Make private.
+ (_Safe_sequence_base::_M_attach_single): Likewise.
+ (_Safe_sequence_base::_M_detach): Likewise.
+ (_Safe_sequence_base::_M_detach_single): Likewise.
+ * include/debug/safe_container.h
+ (_Safe_container::_Safe_container(_Safe_container&&)): Make default.
+ * include/debug/safe_iterator.h
+ (_Safe_iterator::operator++()): Name __scoped_lock instance.
+ * include/debug/safe_iterator.tcc: Remove trailing line.
+ * include/debug/safe_unordered_base.h
+ (_Safe_local_iterator_base::_M_attach): Make protected.
+ (_Safe_local_iterator_base::_M_attach_single): Likewise.
+ (_Safe_local_iterator_base::_M_detach): Likewise.
+ (_Safe_local_iterator_base::_M_detach_single): Likewise.
+ (_Safe_unordered_container_base): Make _Safe_local_iterator_base friend.
+ (_Safe_unordered_container_base::_M_attach_local): Make private.
+ (_Safe_unordered_container_base::_M_attach_local_single): Likewise.
+ (_Safe_unordered_container_base::_M_detach_local): Likewise.
+ (_Safe_unordered_container_base::_M_detach_local_single): Likewise.
+
* include/parallel/algo.h: Generalize usage of std::__iterator_category.
Adjust whitespaces.
friend class bitset;
reference();
- reference(const _Base_ref& __base,
- bitset* __seq __attribute__((__unused__))) _GLIBCXX_NOEXCEPT
+ reference(const _Base_ref& __base, bitset* __seq) _GLIBCXX_NOEXCEPT
: _Base_ref(__base)
, _Safe_iterator_base(__seq, false)
{ }
reference&
operator=(bool __x) _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
+ _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_write)
._M_iterator(*this));
*static_cast<_Base_ref*>(this) = __x;
reference&
operator=(const reference& __x) _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(),
+ _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_read)
._M_iterator(__x));
- _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
+ _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_write)
._M_iterator(*this));
*static_cast<_Base_ref*>(this) = __x;
bool
operator~() const _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
+ _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_read)
._M_iterator(*this));
return ~(*static_cast<const _Base_ref*>(this));
operator bool() const _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
+ _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_read)
._M_iterator(*this));
return *static_cast<const _Base_ref*>(this);
reference&
flip() _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
+ _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(),
_M_message(__gnu_debug::__msg_bad_bitset_flip)
._M_iterator(*this));
_Base_ref::flip();
*/
class _Safe_iterator_base
{
+ friend class _Safe_sequence_base;
+
public:
/** The sequence this iterator references; may be NULL to indicate
a singular iterator. */
__gnu_cxx::__mutex&
_M_get_mutex() throw ();
- public:
/** Attaches this iterator to the given sequence, detaching it
* from whatever sequence it was attached to originally. If the
* new sequence is the NULL pointer, the iterator is left
void
_M_detach_single() throw ();
+ public:
/** Determines if we are attached to the given sequence. */
bool
_M_attached_to(const _Safe_sequence_base* __seq) const
*/
class _Safe_sequence_base
{
+ friend class _Safe_iterator_base;
+
public:
/// The list of mutable iterators that reference this container
_Safe_iterator_base* _M_iterators;
#if __cplusplus >= 201103L
_Safe_sequence_base(const _Safe_sequence_base&) noexcept
: _Safe_sequence_base() { }
+
+ // Move constructor swap iterators.
+ _Safe_sequence_base(_Safe_sequence_base&& __seq) noexcept
+ : _Safe_sequence_base()
+ { _M_swap(__seq); }
#endif
/** Notify all iterators that reference this sequence that the
__gnu_cxx::__mutex&
_M_get_mutex() throw ();
- public:
/** Invalidates all iterators. */
void
_M_invalidate_all() const
{ if (++_M_version == 0) _M_version = 1; }
+ private:
/** Attach an iterator to this sequence. */
void
_M_attach(_Safe_iterator_base* __it, bool __constant);
#if __cplusplus >= 201103L
_Safe_container() = default;
_Safe_container(const _Safe_container&) = default;
- _Safe_container(_Safe_container&& __x) noexcept
- : _Safe_container()
- { _Base::_M_swap(__x); }
+ _Safe_container(_Safe_container&&) = default;
- _Safe_container(_Safe_container&& __x,
- const _Alloc& __a)
+ _Safe_container(_Safe_container&& __x, const _Alloc& __a)
: _Safe_container()
{
if (__x._M_cont().get_allocator() == __a)
_GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(),
_M_message(__msg_bad_inc)
._M_iterator(*this, "this"));
- __gnu_cxx::__scoped_lock(this->_M_get_mutex());
+ __gnu_cxx::__scoped_lock __l(this->_M_get_mutex());
++base();
return *this;
}
} // namespace __gnu_debug
#endif
-
_Safe_unordered_container_base*
_M_get_container() const noexcept;
- public:
/** Attaches this iterator to the given container, detaching it
* from whatever container it was attached to originally. If the
* new container is the NULL pointer, the iterator is left
* unattached.
*/
- void _M_attach(_Safe_sequence_base* __seq, bool __constant);
+ void
+ _M_attach(_Safe_sequence_base* __seq, bool __constant);
/** Likewise, but not thread-safe. */
- void _M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw ();
+ void
+ _M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw ();
/** Detach the iterator for whatever container it is attached to,
* if any.
*/
- void _M_detach();
+ void
+ _M_detach();
/** Likewise, but not thread-safe. */
- void _M_detach_single() throw ();
+ void
+ _M_detach_single() throw ();
};
/**
*/
class _Safe_unordered_container_base : public _Safe_sequence_base
{
+ friend class _Safe_local_iterator_base;
typedef _Safe_sequence_base _Base;
+
public:
/// The list of mutable local iterators that reference this container
_Safe_iterator_base* _M_local_iterators;
void
_M_swap(_Safe_unordered_container_base& __x) noexcept;
- public:
+ private:
/** Attach an iterator to this container. */
void
_M_attach_local(_Safe_iterator_base* __it, bool __constant);