mirror of
https://github.com/boostorg/algorithm.git
synced 2025-06-29 05:50:57 +02:00
Conditionally replace deprecated c++98 features by c++11 ones
change std::random_shuffle -> std::shuffle + random_engine if indicated by the supported language level or Boost configuration macro. Signed-off-by: Daniela Engert <dani@ngrt.de>
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
#if (__cplusplus >= 201103L) || defined(BOOST_NO_CXX98_RANDOM_SHUFFLE)
|
||||
#include <random>
|
||||
|
||||
std::default_random_engine gen;
|
||||
@ -34,7 +34,7 @@ void check_sequence ( Iter first, Iter last, Iter sf, Iter sl )
|
||||
// }
|
||||
// if (sl == last) std::cout << "<";
|
||||
// std::cout << '\n';
|
||||
|
||||
|
||||
if (sf == sl) return;
|
||||
for (Iter i = first; i < sf; ++i)
|
||||
BOOST_CHECK(*i < *sf);
|
||||
@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE( test_main )
|
||||
std::vector<int> v;
|
||||
for ( int i = 0; i < 10; ++i )
|
||||
v.push_back(i);
|
||||
|
||||
|
||||
const std::vector<int>::iterator b = v.begin();
|
||||
ba::partition_subrange(b, v.end(), b + 3, b + 6);
|
||||
check_sequence (b, v.end(), b + 3, b + 6);
|
||||
@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE( test_main )
|
||||
// BOOST_CHECK_EQUAL(v[3], 3);
|
||||
// BOOST_CHECK_EQUAL(v[4], 4);
|
||||
// BOOST_CHECK_EQUAL(v[5], 5);
|
||||
|
||||
|
||||
// Mix them up and try again - single element
|
||||
do_shuffle(v.begin(), v.end());
|
||||
ba::partition_subrange(b, v.end(), b + 7, b + 8);
|
||||
@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE( test_main )
|
||||
std::vector<int> v;
|
||||
for ( int i = 0; i < 10; ++i )
|
||||
v.push_back(i);
|
||||
|
||||
|
||||
const std::vector<int>::iterator b = v.begin();
|
||||
ba::partition_subrange(b, v.end(), b + 3, b + 6, std::greater<int>());
|
||||
check_sequence (b, v.end(), b + 3, b + 6, std::greater<int>());
|
||||
|
Reference in New Issue
Block a user