I find it quite convenient so maybe you'll accept it.

Note that looking for existence of this macro I noticed that ChangeLog-2024 is wrongly talking about _GLIBCXX_USE_ALLOC_PTR_FOR_LIST in <forward_list> header. Should it be fixed ?

    libstdc++: Add _GLIBCXX_USE_ALLOC_PTR macro to rule them all

    Provide a unique way to control usage of the allocator pointer type through a single     macro: _GLIBCXX_USE_ALLOC_PTR. If defined is used to set the value of the following     macros: _GLIBCXX_USE_ALLOC_PTR_FOR_LIST, _GLIBCXX_USE_ALLOC_PTR_FOR_FORWARD_LIST
    and _GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE.

    libstdc++-v3/ChangeLog:

            * include/bits/forward_list.h [_GLIBCXX_USE_ALLOC_PTR_FOR_FORWARD_LIST]:
            Default to _GLIBCXX_USE_ALLOC_PTR if defined.
            * include/bits/stl_list.h [_GLIBCXX_USE_ALLOC_PTR_FOR_LIST]:
            Likewise.
            * include/bits/stl_tree.h [_GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE]:
            Likewise.

Tested under Linux x86_64,

ok to commit ?

François

diff --git a/libstdc++-v3/include/bits/forward_list.h 
b/libstdc++-v3/include/bits/forward_list.h
index 8bcfb809319..b79fc7fea86 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -52,7 +52,11 @@
 #endif
 
 #if ! defined _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
-# define _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST 1
+# ifdef _GLIBCXX_USE_ALLOC_PTR
+#  define _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST _GLIBCXX_USE_ALLOC_PTR
+# else
+#  define _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST 1
+# endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
diff --git a/libstdc++-v3/include/bits/stl_list.h 
b/libstdc++-v3/include/bits/stl_list.h
index d27824c0a7a..ab4271f0e26 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -75,7 +75,11 @@
 # undef _GLIBCXX_USE_ALLOC_PTR_FOR_LIST
 # define _GLIBCXX_USE_ALLOC_PTR_FOR_LIST 0
 #elif ! defined _GLIBCXX_USE_ALLOC_PTR_FOR_LIST
-# define _GLIBCXX_USE_ALLOC_PTR_FOR_LIST 1
+# ifdef _GLIBCXX_USE_ALLOC_PTR
+#  define _GLIBCXX_USE_ALLOC_PTR_FOR_LIST _GLIBCXX_USE_ALLOC_PTR
+# else
+#  define _GLIBCXX_USE_ALLOC_PTR_FOR_LIST 1
+# endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
diff --git a/libstdc++-v3/include/bits/stl_tree.h 
b/libstdc++-v3/include/bits/stl_tree.h
index 4b7f482e794..4fa2be1b7b7 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -79,7 +79,11 @@
 # undef _GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE
 # define _GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE 0
 #elif ! defined _GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE
-# define _GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE 1
+# ifdef _GLIBCXX_USE_ALLOC_PTR
+#  define _GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE _GLIBCXX_USE_ALLOC_PTR
+# else
+#  define _GLIBCXX_USE_ALLOC_PTR_FOR_RB_TREE 1
+# endif
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)

Reply via email to