Re: RFC: [PATCH] Remove using-declarations that add std names to __gnu_cxx

2019-05-31 Thread Jonathan Wakely

On 31/05/19 11:36 +0100, Jonathan Wakely wrote:

On 29/05/19 21:00 +0100, Jonathan Wakely wrote:

These using-declarations appear to have been added for simplicity when
moving the non-standard extensions from namespace std to namespace
__gnu_cxx. Dumping all these names into namespace __gnu_cxx allows
uses like __gnu_cxx::size_t and __gnu_cxx::pair, which serve no useful
purpose, but allows creating unnecessarily unportable code.

This patch removes most of the using-declarations from namespace scope,
then either qualifies names as needed or adds using-declarations at
block scope or typedefs at class scope.

* include/backward/hashtable.h (size_t, ptrdiff_t)
(forward_iterator_tag, input_iterator_tag, _Construct, _Destroy)
(distance, vector, pair, __iterator_category): Remove
using-declarations that add these names to namespace __gnu_cxx.
* include/ext/bitmap_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/debug_allocator.h (size_t): Likewise.
* include/ext/functional (size_t, unary_function, binary_function)
(mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t, const_mem_fun1_ref_t):
Likewise.
* include/ext/malloc_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/memory (ptrdiff_t, pair, __iterator_category): Likewise.
* include/ext/mt_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/new_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/numeric (iota): Fix outdated comment.
* include/ext/pool_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/rb_tree (_Rb_tree, allocator): Likewise.
* include/ext/rope (size_t, ptrdiff_t, allocator, _Destroy): Likewise.
* include/ext/ropeimpl.h (size_t, printf, basic_ostream)
(__throw_length_error, _Destroy, std::__uninitialized_fill_n_a):
Likewise.
* include/ext/slist (size_t, ptrdiff_t, _Construct, _Destroy)
(allocator, __true_type, __false_type): Likewise.

Does anybody think we should keep __gnu_cxx::size_t,
__gnu_cxx::input_iterator_tag, __gnu_cxx::vector, __gnu_cxx::pair etc.
or should I go ahead and commit this?


Committed to trunk.


And this fix is needed to fix an AIX bootstrap failure.

Committed to trunk.


commit e49b5946d09205e57a60a84d764b77a1d2d09a83
Author: Jonathan Wakely 
Date:   Fri May 31 14:58:15 2019 +0100

Fix breakage due to removing __gnu_cxx::size_t declaration

Restore the using-declaration but locally in the source file, not in the
header.

* src/c++98/bitmap_allocator.cc: Add using-declaration for size_t.

diff --git a/libstdc++-v3/src/c++98/bitmap_allocator.cc b/libstdc++-v3/src/c++98/bitmap_allocator.cc
index d22bf4e118f..ffaea1cbac9 100644
--- a/libstdc++-v3/src/c++98/bitmap_allocator.cc
+++ b/libstdc++-v3/src/c++98/bitmap_allocator.cc
@@ -28,6 +28,8 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+  using std::size_t;
+
   namespace __detail
   {
 template class __mini_vector<


Re: RFC: [PATCH] Remove using-declarations that add std names to __gnu_cxx

2019-05-31 Thread Jonathan Wakely

On 29/05/19 21:00 +0100, Jonathan Wakely wrote:

These using-declarations appear to have been added for simplicity when
moving the non-standard extensions from namespace std to namespace
__gnu_cxx. Dumping all these names into namespace __gnu_cxx allows
uses like __gnu_cxx::size_t and __gnu_cxx::pair, which serve no useful
purpose, but allows creating unnecessarily unportable code.

This patch removes most of the using-declarations from namespace scope,
then either qualifies names as needed or adds using-declarations at
block scope or typedefs at class scope.

* include/backward/hashtable.h (size_t, ptrdiff_t)
(forward_iterator_tag, input_iterator_tag, _Construct, _Destroy)
(distance, vector, pair, __iterator_category): Remove
using-declarations that add these names to namespace __gnu_cxx.
* include/ext/bitmap_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/debug_allocator.h (size_t): Likewise.
* include/ext/functional (size_t, unary_function, binary_function)
(mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t, const_mem_fun1_ref_t):
Likewise.
* include/ext/malloc_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/memory (ptrdiff_t, pair, __iterator_category): Likewise.
* include/ext/mt_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/new_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/numeric (iota): Fix outdated comment.
* include/ext/pool_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/rb_tree (_Rb_tree, allocator): Likewise.
* include/ext/rope (size_t, ptrdiff_t, allocator, _Destroy): Likewise.
* include/ext/ropeimpl.h (size_t, printf, basic_ostream)
(__throw_length_error, _Destroy, std::__uninitialized_fill_n_a):
Likewise.
* include/ext/slist (size_t, ptrdiff_t, _Construct, _Destroy)
(allocator, __true_type, __false_type): Likewise.

Does anybody think we should keep __gnu_cxx::size_t,
__gnu_cxx::input_iterator_tag, __gnu_cxx::vector, __gnu_cxx::pair etc.
or should I go ahead and commit this?


Committed to trunk.




Re: RFC: [PATCH] Remove using-declarations that add std names to __gnu_cxx

2019-05-29 Thread Thomas Rodgers
Concur

Ville Voutilainen writes:

> On Wed, 29 May 2019 at 23:00, Jonathan Wakely  wrote:
>> Does anybody think we should keep __gnu_cxx::size_t,
>> __gnu_cxx::input_iterator_tag, __gnu_cxx::vector, __gnu_cxx::pair etc.
>> or should I go ahead and commit this?
>
> +1 go ahead.



Re: RFC: [PATCH] Remove using-declarations that add std names to __gnu_cxx

2019-05-29 Thread Ville Voutilainen
On Wed, 29 May 2019 at 23:00, Jonathan Wakely  wrote:
> Does anybody think we should keep __gnu_cxx::size_t,
> __gnu_cxx::input_iterator_tag, __gnu_cxx::vector, __gnu_cxx::pair etc.
> or should I go ahead and commit this?

+1 go ahead.


RFC: [PATCH] Remove using-declarations that add std names to __gnu_cxx

2019-05-29 Thread Jonathan Wakely

These using-declarations appear to have been added for simplicity when
moving the non-standard extensions from namespace std to namespace
__gnu_cxx. Dumping all these names into namespace __gnu_cxx allows
uses like __gnu_cxx::size_t and __gnu_cxx::pair, which serve no useful
purpose, but allows creating unnecessarily unportable code.

This patch removes most of the using-declarations from namespace scope,
then either qualifies names as needed or adds using-declarations at
block scope or typedefs at class scope.

* include/backward/hashtable.h (size_t, ptrdiff_t)
(forward_iterator_tag, input_iterator_tag, _Construct, _Destroy)
(distance, vector, pair, __iterator_category): Remove
using-declarations that add these names to namespace __gnu_cxx.
* include/ext/bitmap_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/debug_allocator.h (size_t): Likewise.
* include/ext/functional (size_t, unary_function, binary_function)
(mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t, const_mem_fun1_ref_t):
Likewise.
* include/ext/malloc_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/memory (ptrdiff_t, pair, __iterator_category): Likewise.
* include/ext/mt_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/new_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/numeric (iota): Fix outdated comment.
* include/ext/pool_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/rb_tree (_Rb_tree, allocator): Likewise.
* include/ext/rope (size_t, ptrdiff_t, allocator, _Destroy): Likewise.
* include/ext/ropeimpl.h (size_t, printf, basic_ostream)
(__throw_length_error, _Destroy, std::__uninitialized_fill_n_a):
Likewise.
* include/ext/slist (size_t, ptrdiff_t, _Construct, _Destroy)
(allocator, __true_type, __false_type): Likewise.

Does anybody think we should keep __gnu_cxx::size_t,
__gnu_cxx::input_iterator_tag, __gnu_cxx::vector, __gnu_cxx::pair etc.
or should I go ahead and commit this?


commit ab8f45c41ec4ee31e55080af79b728dcb556ef2a
Author: Jonathan Wakely 
Date:   Wed May 29 15:56:59 2019 +0100

Remove using-declarations that add std names to __gnu_cxx

These using-declarations appear to have been added for simplicity when
moving the non-standard extensions from namespace std to namespace
__gnu_cxx. Dumping all these names into namespace __gnu_cxx allows
unportable uses like __gnu_cxx::size_t and __gnu_cxx::pair, which serve
no useful purpose.

This patch removes most of the using-declarations from namespace scope,
then either qualifies names as needed or adds using-declarations at
block scope or typedefs at class scope.

* include/backward/hashtable.h (size_t, ptrdiff_t)
(forward_iterator_tag, input_iterator_tag, _Construct, _Destroy)
(distance, vector, pair, __iterator_category): Remove
using-declarations that add these names to namespace __gnu_cxx.
* include/ext/bitmap_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/debug_allocator.h (size_t): Likewise.
* include/ext/functional (size_t, unary_function, binary_function)
(mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t, 
const_mem_fun1_ref_t):
Likewise.
* include/ext/malloc_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/memory (ptrdiff_t, pair, __iterator_category): 
Likewise.
* include/ext/mt_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/new_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/numeric (iota): Fix outdated comment.
* include/ext/pool_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/rb_tree (_Rb_tree, allocator): Likewise.
* include/ext/rope (size_t, ptrdiff_t, allocator, _Destroy): 
Likewise.
* include/ext/ropeimpl.h (size_t, printf, basic_ostream)
(__throw_length_error, _Destroy, std::__uninitialized_fill_n_a):
Likewise.
* include/ext/slist (size_t, ptrdiff_t, _Construct, _Destroy)
(allocator, __true_type, __false_type): Likewise.

diff --git a/libstdc++-v3/include/backward/hashtable.h 
b/libstdc++-v3/include/backward/hashtable.h
index 28c487a71c2..df6ad85191c 100644
--- a/libstdc++-v3/include/backward/hashtable.h
+++ b/libstdc++-v3/include/backward/hashtable.h
@@ -69,17 +69,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  using std::size_t;
-  using std::ptrdiff_t;
-  using std::forward_iterator_tag;
-  using std::input_iterator_tag;
-  using std::_Construct;
-  using std::_Destroy;
-  using std::distance;
-  using std::vector;
-  using std::pair;
-  using std::__iterator_category;
-
   template
 struct _Hashtable_node
 {
@@ -112,10 +101,10 @@