libstdc++: Deprecate std::random_shuffle for C++14
The std::random_shuffle algorithm was removed in C++14 (without deprecation). This adds the deprecated attribute for C++14 and later, so that users are warned they should not be using it in those dialects. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * doc/xml/manual/evolution.xml: Document deprecation. * doc/html/*: Regenerate. * include/bits/c++config (_GLIBCXX14_DEPRECATED): Define. (_GLIBCXX14_DEPRECATED_SUGGEST): Define. * include/bits/stl_algo.h (random_shuffle): Deprecate for C++14 and later. * testsuite/25_algorithms/headers/algorithm/synopsis.cc: Adjust for C++11 and C++14 changes to std::random_shuffle and std::shuffle. * testsuite/25_algorithms/random_shuffle/1.cc: Add options to use deprecated algorithms. * testsuite/25_algorithms/random_shuffle/59603.cc: Likewise. * testsuite/25_algorithms/random_shuffle/moveable.cc: Likewise. * testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc: Likewise. * testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc: Likewise.
This commit is contained in:
parent
07b70dfc4e
commit
7f2f4b8791
File diff suppressed because one or more lines are too long
@ -436,4 +436,8 @@ now defaults to zero.
|
||||
Calling <code class="function">reserve()</code> with no arguments is equivalent
|
||||
to <code class="function">shrink_to_fit()</code>, but is deprecated.
|
||||
<code class="function">shrink_to_fit()</code> should be used instead.
|
||||
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="api.rel_121"></a><code class="constant">12</code></h3></div></div></div><p>
|
||||
The <code class="function">std::random_shuffle</code> algorithms are deprecated
|
||||
for C++14 and later. The C++11 <code class="function">std::shuffle</code> algorithm
|
||||
can be used instead.
|
||||
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="abi.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="backwards.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ABI Policy and Guidelines </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Backwards Compatibility</td></tr></table></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1019,4 +1019,14 @@ now defaults to zero.
|
||||
|
||||
</section>
|
||||
|
||||
<section xml:id="api.rel_121"><info><title><constant>12</constant></title></info>
|
||||
|
||||
<para>
|
||||
The <function>std::random_shuffle</function> algorithms are deprecated
|
||||
for C++14 and later. The C++11 <function>std::shuffle</function> algorithm
|
||||
can be used instead.
|
||||
</para>
|
||||
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
@ -80,6 +80,8 @@
|
||||
// _GLIBCXX_DEPRECATED_SUGGEST( string-literal )
|
||||
// _GLIBCXX11_DEPRECATED
|
||||
// _GLIBCXX11_DEPRECATED_SUGGEST( string-literal )
|
||||
// _GLIBCXX14_DEPRECATED
|
||||
// _GLIBCXX14_DEPRECATED_SUGGEST( string-literal )
|
||||
// _GLIBCXX17_DEPRECATED
|
||||
// _GLIBCXX17_DEPRECATED_SUGGEST( string-literal )
|
||||
// _GLIBCXX20_DEPRECATED( string-literal )
|
||||
@ -105,6 +107,14 @@
|
||||
# define _GLIBCXX11_DEPRECATED_SUGGEST(ALT)
|
||||
#endif
|
||||
|
||||
#if defined(__DEPRECATED) && (__cplusplus >= 201403L)
|
||||
# define _GLIBCXX14_DEPRECATED _GLIBCXX_DEPRECATED
|
||||
# define _GLIBCXX14_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
|
||||
#else
|
||||
# define _GLIBCXX14_DEPRECATED
|
||||
# define _GLIBCXX14_DEPRECATED_SUGGEST(ALT)
|
||||
#endif
|
||||
|
||||
#if defined(__DEPRECATED) && (__cplusplus >= 201703L)
|
||||
# define _GLIBCXX17_DEPRECATED [[__deprecated__]]
|
||||
# define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
|
||||
|
@ -56,7 +56,6 @@
|
||||
#ifndef _STL_ALGO_H
|
||||
#define _STL_ALGO_H 1
|
||||
|
||||
#include <cstdlib> // for rand
|
||||
#include <bits/algorithmfwd.h>
|
||||
#include <bits/stl_heap.h>
|
||||
#include <bits/stl_tempbuf.h> // for _Temporary_buffer
|
||||
@ -66,6 +65,10 @@
|
||||
#include <bits/uniform_int_dist.h>
|
||||
#endif
|
||||
|
||||
#if _GLIBCXX_HOSTED && (__cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED)
|
||||
#include <cstdlib> // for rand
|
||||
#endif
|
||||
|
||||
// See concept_check.h for the __glibcxx_*_requires macros.
|
||||
|
||||
namespace std _GLIBCXX_VISIBILITY(default)
|
||||
@ -4551,6 +4554,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
|
||||
std::__iterator_category(__result));
|
||||
}
|
||||
|
||||
#if __cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED
|
||||
#if _GLIBCXX_HOSTED
|
||||
/**
|
||||
* @brief Randomly shuffle the elements of a sequence.
|
||||
@ -4564,6 +4568,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
|
||||
* equally likely.
|
||||
*/
|
||||
template<typename _RandomAccessIterator>
|
||||
_GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle")
|
||||
inline void
|
||||
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
@ -4599,6 +4604,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
|
||||
* range [0,N).
|
||||
*/
|
||||
template<typename _RandomAccessIterator, typename _RandomNumberGenerator>
|
||||
_GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle")
|
||||
void
|
||||
random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
#if __cplusplus >= 201103L
|
||||
@ -4621,7 +4627,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
|
||||
std::iter_swap(__i, __j);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // C++11 || USE_DEPRECATED
|
||||
|
||||
/**
|
||||
* @brief Move elements for which a predicate is true to the beginning
|
||||
|
@ -318,6 +318,7 @@ namespace std
|
||||
_OIter
|
||||
rotate_copy (_FIter, _FIter, _FIter, _OIter);
|
||||
|
||||
#if __cplusplus <= 201103L
|
||||
template<typename _RAIter>
|
||||
void
|
||||
random_shuffle(_RAIter, _RAIter);
|
||||
@ -325,6 +326,13 @@ namespace std
|
||||
template<typename _RAIter, typename _Generator>
|
||||
void
|
||||
random_shuffle(_RAIter, _RAIter, _Generator&);
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _RAIter, typename _UniformRandomBitGenerator>
|
||||
void
|
||||
shuffle(_RAIter, _RAIter, _UniformRandomBitGenerator&);
|
||||
#endif
|
||||
|
||||
// 25.2.12, partitions:
|
||||
template<typename _BIter, typename _Predicate>
|
||||
|
@ -15,6 +15,8 @@
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-add-options using-deprecated }
|
||||
|
||||
// 25.2.11 random_shuffle()
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -16,6 +16,7 @@
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-add-options using-deprecated }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
// libstdc++/59603
|
||||
|
@ -1,4 +1,5 @@
|
||||
// { dg-do run { target c++11 } }
|
||||
// { dg-add-options using-deprecated }
|
||||
|
||||
// Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
||||
//
|
||||
|
@ -1,4 +1,5 @@
|
||||
// { dg-do compile }
|
||||
// { dg-add-options using-deprecated }
|
||||
|
||||
// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// { dg-do compile }
|
||||
// { dg-add-options using-deprecated }
|
||||
|
||||
// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user