Index: include/algorithm =================================================================== --- include/algorithm +++ include/algorithm @@ -281,12 +281,12 @@ template 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 void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, - RandomNumberGenerator& rand); // deprecated in C++14 + RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17 template @@ -3026,6 +3026,7 @@ return static_cast(__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 @@ } } } +#endif template Index: test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp =================================================================== --- test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp +++ 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last); +// +// template +// 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 , then random_shuffle will be restored. + +#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE + +#include +#include + +struct gen +{ + std::ptrdiff_t operator()(std::ptrdiff_t n) + { + return n-1; + } +}; + + +int main() +{ + std::vector v; + std::random_shuffle(v.begin(), v.end()); + gen r; + std::random_shuffle(v.begin(), v.end(), r); +} Index: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // template // requires ShuffleIterator Index: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp =================================================================== --- test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp +++ test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // template Rand> // requires ShuffleIterator