From 198e5dc737b64ba985f383cf84a4ec149cde6b54 Mon Sep 17 00:00:00 2001 From: a-andre <13609565+a-andre@users.noreply.github.com> Date: Mon, 26 Aug 2024 09:40:32 +0200 Subject: [PATCH] Replace coinDistance() by std::distance() (#241) * Remove SUNPRO switch from coinDistance() The Sun/Oracle compiler should follow the standard by now. * Replace coinDistance() by std::distance() --- src/CoinDistance.hpp | 14 +------------- src/CoinSort.hpp | 14 +++++++------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/CoinDistance.hpp b/src/CoinDistance.hpp index 00c44ec52..66e7eb91f 100644 --- a/src/CoinDistance.hpp +++ b/src/CoinDistance.hpp @@ -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 diff --git a/src/CoinSort.hpp b/src/CoinSort.hpp index bc827504d..81b9ec70d 100644 --- a/src/CoinSort.hpp +++ b/src/CoinSort.hpp @@ -8,7 +8,7 @@ #include #include #include -#include "CoinDistance.hpp" +#include // Uncomment the next three lines to get thorough initialisation of memory. // #ifndef ZEROFAULT @@ -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; @@ -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; @@ -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) { @@ -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]; @@ -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; @@ -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;