We already have these attributes on the definitions in <bits/stl_algo.h>
but they don't work due to PR c++/84542. Add the attributes to the
declarations in <bits/algorithmfwd.h> as well, and add a test.
libstdc++-v3/ChangeLog:
* include/bits/algorithmfwd.h (random_shuffle): Add deprecated
attribute.
* include/bits/stl_algo.h (random_shuffle): Correct comments.
* testsuite/25_algorithms/random_shuffle/1.cc: Disable
deprecated warnings.
* testsuite/25_algorithms/random_shuffle/59603.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/moveable.cc: Likewise.
* testsuite/25_algorithms/random_shuffle/deprecated.cc: New
test.
(cherry picked from commit
c01b344e814001e07fd304ce98d013d811e90192)
partition(_BIter, _BIter, _Predicate);
template<typename _RAIter>
+ _GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle")
void
random_shuffle(_RAIter, _RAIter);
template<typename _RAIter, typename _Generator>
+ _GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle")
void
random_shuffle(_RAIter, _RAIter,
#if __cplusplus >= 201103L
* equally likely.
*
* @deprecated
- * Since C++14 `std::random_shuffle` is not part of the C++ standard.
+ * Since C++17, `std::random_shuffle` is not part of the C++ standard.
* Use `std::shuffle` instead, which was introduced in C++11.
*/
template<typename _RandomAccessIterator>
* range [0,N).
*
* @deprecated
- * Since C++14 `std::random_shuffle` is not part of the C++ standard.
+ * Since C++17, `std::random_shuffle` is not part of the C++ standard.
* Use `std::shuffle` instead, which was introduced in C++11.
*/
template<typename _RandomAccessIterator, typename _RandomNumberGenerator>
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+// { dg-options "-Wno-deprecated-declarations" }
// { dg-add-options using-deprecated }
// 25.2.11 random_shuffle()
// <http://www.gnu.org/licenses/>.
// { dg-do run { target c++11 } }
+// { dg-options "-Wno-deprecated-declarations" }
// { dg-add-options using-deprecated }
// { dg-require-debug-mode "" }
--- /dev/null
+// { dg-do compile }
+// { dg-add-options using-deprecated }
+
+// std::random_shuffle was deprecated in C++17 and removed in C++17.
+
+#include <algorithm>
+
+std::ptrdiff_t rando(std::ptrdiff_t n);
+
+void
+test_depr(int* first, int* last)
+{
+ std::random_shuffle(first, last);
+ // { dg-warning "deprecated" "" { target c++14 } 13 }
+
+ std::random_shuffle(first, last, rando);
+ // { dg-warning "deprecated" "" { target c++14 } 16 }
+}
// { dg-do run { target c++11 } }
+// { dg-options "-Wno-deprecated-declarations" }
// { dg-add-options using-deprecated }
// Copyright (C) 2009-2022 Free Software Foundation, Inc.