summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-03-23 13:43:37 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-03-23 13:43:37 +0000
commit0f37a410293c8b507f51556eed5954d1a2fb0499 (patch)
tree7006292095aa2f953cf5504f60406745610e524d
parentf9fa62e576d63bf7b1b9ecc9665f4c9ab654ce58 (diff)
downloadbcm5719-llvm-0f37a410293c8b507f51556eed5954d1a2fb0499.tar.gz
bcm5719-llvm-0f37a410293c8b507f51556eed5954d1a2fb0499.zip
Remove random_shuffle in C++17. Please use shuffle instead. If you have to, you cant get it back by defining _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE before including any libc++ headers.
llvm-svn: 298597
-rw-r--r--libcxx/include/algorithm6
-rw-r--r--libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp46
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp1
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp1
4 files changed, 52 insertions, 2 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 5eec80ca013..bba6d8d3d66 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -281,12 +281,12 @@ template <class ForwardIterator, class OutputIterator>
template <class RandomAccessIterator>
void
- random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14
+ random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
template <class RandomAccessIterator, class RandomNumberGenerator>
void
random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
- RandomNumberGenerator& rand); // deprecated in C++14
+ RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
template<class PopulationIterator, class SampleIterator,
class Distance, class UniformRandomBitGenerator>
@@ -3026,6 +3026,7 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
return static_cast<result_type>(__u + __p.a());
}
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE)
class _LIBCPP_TYPE_VIS __rs_default;
_LIBCPP_FUNC_VIS __rs_default __rs_get();
@@ -3095,6 +3096,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
}
}
}
+#endif
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
diff --git a/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp b/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
new file mode 100644
index 00000000000..8214e1e2068
--- /dev/null
+++ b/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class RandomAccessIterator>
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
+//
+// template <class RandomAccessIterator, class RandomNumberGenerator>
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+// RandomNumberGenerator& rand);
+
+//
+// In C++17, random_shuffle has been removed.
+// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+// is defined before including <algorithm>, then random_shuffle will be restored.
+
+#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+
+#include <algorithm>
+#include <vector>
+
+struct gen
+{
+ std::ptrdiff_t operator()(std::ptrdiff_t n)
+ {
+ return n-1;
+ }
+};
+
+
+int main()
+{
+ std::vector<int> v;
+ std::random_shuffle(v.begin(), v.end());
+ gen r;
+ std::random_shuffle(v.begin(), v.end(), r);
+}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
index e24598a9bc1..77d7153e4e2 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// <algorithm>
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
// template<RandomAccessIterator Iter>
// requires ShuffleIterator<Iter>
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
index c923d847f11..2424c7732db 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// <algorithm>
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
// template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand>
// requires ShuffleIterator<Iter>
OpenPOWER on IntegriCloud