Re: safe unordered local iterators

2011-07-20 Thread Jonathan Wakely
See http://gcc.gnu.org/ml/gcc/2011-07/msg00368.html

Should code inside namespace __gnu_debug be using std::size_t instead
of assuming ::size_t has been declared?


Re: safe unordered local iterators

2011-07-20 Thread Jonathan Wakely
On 20 July 2011 09:38, Jonathan Wakely wrote:
> See http://gcc.gnu.org/ml/gcc/2011-07/msg00368.html
>
> Should code inside namespace __gnu_debug be using std::size_t instead
> of assuming ::size_t has been declared?
>

Or maybe that use (which is the only unqualified size_t I see in
include/debug/* outside of namespace std) should be using size_type
anyway.


Re: safe unordered local iterators

2011-07-20 Thread Jonathan Wakely
On 20 July 2011 09:51, Jonathan Wakely wrote:
> On 20 July 2011 09:38, Jonathan Wakely wrote:
>> See http://gcc.gnu.org/ml/gcc/2011-07/msg00368.html
>>
>> Should code inside namespace __gnu_debug be using std::size_t instead
>> of assuming ::size_t has been declared?
>>
>
> Or maybe that use (which is the only unqualified size_t I see in
> include/debug/* outside of namespace std) should be using size_type
> anyway.
>

Also (sorry for not noticing sooner) the unordered containers are not
Sequences (as defined by the standard library) so the file names
safe_unordered_sequence.* are inaccurate.  We already have this
problem with _Safe_sequence used for debug maps and sets, but at least
_Safe_sequence is also used as the base for the Sequence containers,
vector, list etc.


Re: safe unordered local iterators

2011-07-20 Thread Paolo Carlini

On 07/20/2011 10:51 AM, Jonathan Wakely wrote:

On 20 July 2011 09:38, Jonathan Wakely wrote:

See http://gcc.gnu.org/ml/gcc/2011-07/msg00368.html

Should code inside namespace __gnu_debug be using std::size_t instead
of assuming ::size_t has been declared?


Or maybe that use (which is the only unqualified size_t I see in
include/debug/* outside of namespace std) should be using size_type
anyway.
Indeed. I applied the below, to resolve this pressing issue, Jonathan 
will hopefully provide soon feedback about the naming issue.


Paolo.

/
2011-07-20  Paolo Carlini  

* include/debug/safe_local_iterator.h (_Safe_local_iterator<>::
_Safe_local_iterator(const _Iterator&, size_type, const _Sequence*)):
Fix typo.
Index: include/debug/safe_local_iterator.h
===
--- include/debug/safe_local_iterator.h (revision 176499)
+++ include/debug/safe_local_iterator.h (working copy)
@@ -88,7 +88,7 @@
* @pre @p seq is not NULL
* @post this is not singular
*/
-  _Safe_local_iterator(const _Iterator& __i, size_t __bucket,
+  _Safe_local_iterator(const _Iterator& __i, size_type __bucket,
   const _Sequence* __seq)
   : _Safe_local_iterator_base(__seq, _M_constant()), _M_current(__i),
_M_bucket(__bucket)


Re: safe unordered local iterators

2011-07-20 Thread Paolo Carlini

On 07/20/2011 11:42 AM, Paolo Carlini wrote:

On 07/20/2011 10:51 AM, Jonathan Wakely wrote:

On 20 July 2011 09:38, Jonathan Wakely wrote:

See http://gcc.gnu.org/ml/gcc/2011-07/msg00368.html

Should code inside namespace __gnu_debug be using std::size_t instead
of assuming ::size_t has been declared?


Or maybe that use (which is the only unqualified size_t I see in
include/debug/* outside of namespace std) should be using size_type
anyway.
Indeed. I applied the below, to resolve this pressing issue, Jonathan 
will hopefully provide soon feedback about the naming issue.

I meant Francois of course ;)

Paolo.


Re: safe unordered local iterators

2011-07-21 Thread François Dumont

Attached patch applied:

2011-07-21  François Dumont 

* include/debug/safe_unordered_sequence.h,
safe_unordered_sequence.tcc: Rename respectively in...
* include/debug/safe_unordered_container.h,
safe_unordered_container.tcc: ...those. _Safe_unordered_sequence
rename _Safe_unordered_container.
* include/debug/safe_unordered_base.h: 
_Safe_unordered_sequence_base

rename _Safe_unordered_container_base.
* include/debug/unordered_map, unordered_set: Adapt to previous
modifications.
* config/abi/pre/gnu.ver: Likewise.
* src/debug.cc: Likewise.
* include/Makefile.am: Likewise.
* include/Makefile.in: Regenerate.

Regards


On 07/21/2011 12:58 AM, Jonathan Wakely wrote:

On 20 July 2011 22:40, Paolo Carlini  wrote:

On 07/20/2011 10:46 PM, François Dumont wrote:

Hello

Sorry for the inconvenience. Here is my proposition for the renaming, I

I should probably apologise for the inconvenience for suggesting
changing it!  I do think it is a bit confusing though, the "Sequence"
containers in the standard library have a definite ordering, so an
unordered sequence is confusing :)


haven't tested it yet but will of course before commiting.

I'm Ok with it if Jonathan is...

Yes, thanks for changing it.


Thanks,
Paolo.

PS: my first language obviously isn't English, but I see you are using
  a lot where I would normally prefer...

Yes, proposal would be correct there.



Index: src/debug.cc
===
--- src/debug.cc	(revision 176533)
+++ src/debug.cc	(working copy)
@@ -25,7 +25,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -78,8 +78,8 @@
   }
 
   void
-  swap_useq(__gnu_debug::_Safe_unordered_sequence_base& __lhs,
-	__gnu_debug::_Safe_unordered_sequence_base& __rhs)
+  swap_ucont(__gnu_debug::_Safe_unordered_container_base& __lhs,
+	__gnu_debug::_Safe_unordered_container_base& __rhs)
   {
 swap_seq(__lhs, __rhs);
 swap_its(__lhs, __lhs._M_local_iterators,
@@ -174,8 +174,8 @@
 " by a dereferenceable one",
 "function requires a valid iterator range (%2.name;, %3.name;)"
 ", \"%2.name;\" shall be before and not equal to \"%3.name;\"",
-// std::unordered_sequence::local_iterator
-"attempt to compare local iterators from different unordered sequence"
+// std::unordered_container::local_iterator
+"attempt to compare local iterators from different unordered container"
 " buckets"
   };
 
@@ -374,38 +374,38 @@
   _M_get_mutex() throw ()
   { return get_safe_base_mutex(_M_sequence); }
 
-  _Safe_unordered_sequence_base*
+  _Safe_unordered_container_base*
   _Safe_local_iterator_base::
-  _M_get_sequence() const _GLIBCXX_NOEXCEPT
-  { return static_cast<_Safe_unordered_sequence_base*>(_M_sequence); }
+  _M_get_container() const _GLIBCXX_NOEXCEPT
+  { return static_cast<_Safe_unordered_container_base*>(_M_sequence); }
 
   void
   _Safe_local_iterator_base::
-  _M_attach(_Safe_sequence_base* __seq, bool __constant)
+  _M_attach(_Safe_sequence_base* __cont, bool __constant)
   {
 _M_detach();
 
-// Attach to the new sequence (if there is one)
-if (__seq)
+// Attach to the new container (if there is one)
+if (__cont)
   {
-	_M_sequence = __seq;
+	_M_sequence = __cont;
 	_M_version = _M_sequence->_M_version;
-	_M_get_sequence()->_M_attach_local(this, __constant);
+	_M_get_container()->_M_attach_local(this, __constant);
   }
   }
   
   void
   _Safe_local_iterator_base::
-  _M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw ()
+  _M_attach_single(_Safe_sequence_base* __cont, bool __constant) throw ()
   {
 _M_detach_single();
 
-// Attach to the new sequence (if there is one)
-if (__seq)
+// Attach to the new container (if there is one)
+if (__cont)
   {
-	_M_sequence = __seq;
+	_M_sequence = __cont;
 	_M_version = _M_sequence->_M_version;
-	_M_get_sequence()->_M_attach_local_single(this, __constant);
+	_M_get_container()->_M_attach_local_single(this, __constant);
   }
   }
 
@@ -414,7 +414,7 @@
   _M_detach()
   {
 if (_M_sequence)
-  _M_get_sequence()->_M_detach_local(this);
+  _M_get_container()->_M_detach_local(this);
 
 _M_reset();
   }
@@ -424,13 +424,13 @@
   _M_detach_single() throw ()
   {
 if (_M_sequence)
-  _M_get_sequence()->_M_detach_local_single(this);
+  _M_get_container()->_M_detach_local_single(this);
 
 _M_reset();
   }
 
   void
-  _Safe_unordered_sequence_base::
+  _Safe_unordered_container_base::
   _M_detach_all()
   {
 __gnu_cxx::__scoped_lock sentry(_M_get_mutex());
@@ -448,17 +448,17 @@
   }
 
   void
-  _Safe_unordered_sequence_base::
-  _M_swap(_Safe_unordered_sequence_base& __x)
+  _Safe_unordered_container_base::
+  _M_swap(_Safe_unordered_container_base& __x)
   {
-// We need to lock both sequences to swap
+// We need to lock