From mboxrd@z Thu Jan 1 00:00:00 1970
Return-Path:
Received: by sourceware.org (Postfix, from userid 2181)
id CAE523858D20; Thu, 17 Feb 2022 23:44:59 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAE523858D20
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="utf-8"
From: Jonathan Wakely
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-7289] libstdc++: Deprecate non-standard
std::vector::insert(pos) [PR104559]
X-Act-Checkin: gcc
X-Git-Author: Jonathan Wakely
X-Git-Refname: refs/heads/master
X-Git-Oldrev: 2c9b7077b72529fbbe896212a0088bff6025c5e7
X-Git-Newrev: 12a88e6e208fa45a449775bfb9353c777a6081aa
Message-Id: <20220217234459.CAE523858D20@sourceware.org>
Date: Thu, 17 Feb 2022 23:44:59 +0000 (GMT)
X-BeenThere: libstdc++-cvs@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Libstdc++-cvs mailing list
List-Unsubscribe: ,
List-Archive:
List-Help:
List-Subscribe: ,
X-List-Received-Date: Thu, 17 Feb 2022 23:44:59 -0000
https://gcc.gnu.org/g:12a88e6e208fa45a449775bfb9353c777a6081aa
commit r12-7289-g12a88e6e208fa45a449775bfb9353c777a6081aa
Author: Jonathan Wakely
Date: Thu Feb 17 17:37:42 2022 +0000
libstdc++: Deprecate non-standard std::vector::insert(pos) [PR104559]
The SGI STL and pre-1998 drafts of the C++ standard had a default
argument for vector::insert(iterator, const bool&) which was
remove by N1051. The default argument is still present in libstdc++ for
some reason. There are no tests verifying it as an extension, so I don't
think it has been kept intentionally.
This removes the default argument but adds an overload without the
second parameter, and adds the deprecated attribute to it. This allows
any code using it to keep working (for now) but with a warning.
libstdc++-v3/ChangeLog:
PR libstdc++/104559
* doc/xml/manual/evolution.xml: Document deprecation.
* doc/html/manual/api.html: Regenerate.
* include/bits/stl_bvector.h (insert(const_iterator, const bool&)):
Remove default argument.
(insert(const_iterator)): New overload with deprecated attribute.
* testsuite/23_containers/vector/bool/modifiers/insert/104559.cc:
New test.
Diff:
---
libstdc++-v3/doc/html/manual/api.html | 3 +++
libstdc++-v3/doc/xml/manual/evolution.xml | 3 +++
libstdc++-v3/include/bits/stl_bvector.h | 11 +++++++++--
.../23_containers/vector/bool/modifiers/insert/104559.cc | 13 +++++++++++++
4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html
index 26087775708..bbda6f5acf3 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -454,6 +454,9 @@ were deprecated for C++11.
were deprecated for C++17.
Non-standard std::pair
constructors were deprecated.
+A non-standard default argument for
+vector<bool>::insert(const_iterator, const bool&)
+was deprecated.
The bitmap
, mt
, and pool
options for --enable-libstdcxx-allocator
were removed.
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml
index f5bc6471465..4923e8c4783 100644
--- a/libstdc++-v3/doc/xml/manual/evolution.xml
+++ b/libstdc++-v3/doc/xml/manual/evolution.xml
@@ -1045,6 +1045,9 @@ were deprecated for C++17.
Non-standard std::pair
constructors were deprecated.
+A non-standard default argument for
+vector<bool>::insert(const_iterator, const bool&)
+was deprecated.
diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h
index 75f38812807..d256af40f40 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -1135,9 +1135,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_GLIBCXX20_CONSTEXPR
iterator
#if __cplusplus >= 201103L
- insert(const_iterator __position, const bool& __x = bool())
+ insert(const_iterator __position, const bool& __x)
#else
- insert(iterator __position, const bool& __x = bool())
+ insert(iterator __position, const bool& __x)
#endif
{
const difference_type __n = __position - begin();
@@ -1149,6 +1149,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return begin() + __n;
}
+#if _GLIBCXX_USE_DEPRECATED
+ _GLIBCXX_DEPRECATED_SUGGEST("insert(position, false)")
+ iterator
+ insert(const_iterator __position)
+ { return this->insert(__position._M_const_cast(), false); }
+#endif
+
#if __cplusplus >= 201103L
template>
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/104559.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/104559.cc
new file mode 100644
index 00000000000..1121827477f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/104559.cc
@@ -0,0 +1,13 @@
+// { dg-options "-Wdeprecated" }
+// { dg-do compile }
+// { dg-require-normal-mode "" }
+
+#include
+
+void
+test01()
+{
+ std::vector v;
+ v.insert(v.begin(), false);
+ v.insert(v.begin()); // { dg-warning "deprecated" }
+}