mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-04 08:16:31 +02:00
Make apply_permutation work for C++03. Thanks to @jeking3 for the report.
This commit is contained in:
@ -41,15 +41,16 @@ void
|
||||
apply_permutation(RandomAccessIterator1 item_begin, RandomAccessIterator1 item_end,
|
||||
RandomAccessIterator2 ind_begin, RandomAccessIterator2 ind_end)
|
||||
{
|
||||
using Diff = typename std::iterator_traits<RandomAccessIterator1>::difference_type;
|
||||
typedef typename std::iterator_traits<RandomAccessIterator1>::difference_type Diff;
|
||||
typedef typename std::iterator_traits<RandomAccessIterator2>::difference_type Index;
|
||||
using std::swap;
|
||||
Diff size = std::distance(item_begin, item_end);
|
||||
for (Diff i = 0; i < size; i++)
|
||||
{
|
||||
auto current = i;
|
||||
Diff current = i;
|
||||
while (i != ind_begin[current])
|
||||
{
|
||||
auto next = ind_begin[current];
|
||||
Index next = ind_begin[current];
|
||||
swap(item_begin[current], item_begin[next]);
|
||||
ind_begin[current] = current;
|
||||
current = next;
|
||||
@ -75,7 +76,7 @@ apply_reverse_permutation(
|
||||
RandomAccessIterator2 ind_begin,
|
||||
RandomAccessIterator2 ind_end)
|
||||
{
|
||||
using Diff = typename std::iterator_traits<RandomAccessIterator2>::difference_type;
|
||||
typedef typename std::iterator_traits<RandomAccessIterator2>::difference_type Diff;
|
||||
using std::swap;
|
||||
Diff length = std::distance(item_begin, item_end);
|
||||
for (Diff i = 0; i < length; i++)
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include <boost/algorithm/apply_permutation.hpp>
|
||||
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#define BOOST_TEST_MAIN
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
Reference in New Issue
Block a user