Skip to content

Commit

Permalink
Replace coinDistance() by std::distance() (#241)
Browse files Browse the repository at this point in the history
* Remove SUNPRO switch from coinDistance()

The Sun/Oracle compiler should follow the standard by now.

* Replace coinDistance() by std::distance()
  • Loading branch information
a-andre authored Aug 26, 2024
1 parent 4b930fe commit 198e5dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
14 changes: 1 addition & 13 deletions src/CoinDistance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,13 @@ template < class ForwardIterator, class Distance >
void coinDistance(ForwardIterator first, ForwardIterator last,
Distance &n)
{
#if defined(__SUNPRO_CC)
n = 0;
std::distance(first, last, n);
#else
n = std::distance(first, last);
#endif
}

template < class ForwardIterator >
size_t coinDistance(ForwardIterator first, ForwardIterator last)
{
size_t retVal;
#if defined(__SUNPRO_CC)
retVal = 0;
std::distance(first, last, retVal);
#else
retVal = std::distance(first, last);
#endif
return retVal;
return std::distance(first, last);
}

#endif
Expand Down
14 changes: 7 additions & 7 deletions src/CoinSort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <functional>
#include <new>
#include <algorithm>
#include "CoinDistance.hpp"
#include <iterator>

// Uncomment the next three lines to get thorough initialisation of memory.
// #ifndef ZEROFAULT
Expand Down Expand Up @@ -167,7 +167,7 @@ void CoinSort_2(Iter_S sfirst, Iter_S slast, Iter_T tfirst, const CoinCompare2 &
{
typedef typename std::iterator_traits< Iter_S >::value_type S;
typedef typename std::iterator_traits< Iter_T >::value_type T;
const size_t len = coinDistance(sfirst, slast);
const size_t len = std::distance(sfirst, slast);
if (len <= 1)
return;

Expand Down Expand Up @@ -209,7 +209,7 @@ void CoinSort_2(Iter_S sfirst, Iter_S slast, Iter_T tfirst)
template < class S, class T, class CoinCompare2 >
void CoinSort_2(S *sfirst, S *slast, T *tfirst, const CoinCompare2 &pc)
{
const size_t len = coinDistance(sfirst, slast);
const size_t len = std::distance(sfirst, slast);
if (len <= 1)
return;

Expand Down Expand Up @@ -262,7 +262,7 @@ extern int boundary_sort3;
template < class S, class T >
void CoinSort_2(S *key, S *lastKey, T *array2)
{
const size_t number = coinDistance(key, lastKey);
const size_t number = std::distance(key, lastKey);
if (number <= 1) {
return;
} else if (number > 10000) {
Expand Down Expand Up @@ -392,7 +392,7 @@ void CoinSort_2(S *key, S *lastKey, T *array2)
template < class S, class T >
void CoinShortSort_2(S *key, S *lastKey, T *array2)
{
const size_t number = coinDistance(key, lastKey);
const size_t number = std::distance(key, lastKey);
if (number <= 2) {
if (number == 2 && key[0] > key[1]) {
S tempS = key[0];
Expand Down Expand Up @@ -664,7 +664,7 @@ void CoinSort_3(Iter_S sfirst, Iter_S slast, Iter_T tfirst, Iter_U, ufirst,
typedef typename std::iterator_traits< Iter_S >::value_type S;
typedef typename std::iterator_traits< Iter_T >::value_type T;
typedef typename std::iterator_traits< Iter_U >::value_type U;
const size_t len = coinDistance(sfirst, slast);
const size_t len = std::distance(sfirst, slast);
if (len <= 1)
return;

Expand Down Expand Up @@ -707,7 +707,7 @@ void CoinSort_3(Iter_S sfirst, Iter_S slast, Iter_T tfirst, Iter_U, ufirst)
template < class S, class T, class U, class CoinCompare3 >
void CoinSort_3(S *sfirst, S *slast, T *tfirst, U *ufirst, const CoinCompare3 &tc)
{
const size_t len = coinDistance(sfirst, slast);
const size_t len = std::distance(sfirst, slast);
if (len <= 1)
return;

Expand Down

0 comments on commit 198e5dc

Please sign in to comment.