Make apply_permutation work for C++03. Thanks to @jeking3 for the report.

This commit is contained in:
Marshall Clow
2018-10-30 15:23:29 -07:00
parent bf2b49e57e
commit b6c04d6dc5
2 changed files with 5 additions and 5 deletions

View File

@ -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++)

View File

@ -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>