From 63c85e7c5ea56a82b723eedfc5d8902ba2ee5474 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 10 Jan 2018 10:26:21 -0800 Subject: [PATCH] Qualify calls to Boost.Algorithm algs that have the same name as ones in the standard; prevents ADL ambiguities. Thanks to Billy O'Neill for the heads up. --- include/boost/algorithm/clamp.hpp | 10 +++++----- include/boost/algorithm/cxx17/exclusive_scan.hpp | 2 +- include/boost/algorithm/cxx17/inclusive_scan.hpp | 4 ++-- include/boost/algorithm/cxx17/reduce.hpp | 10 +++++----- .../boost/algorithm/cxx17/transform_inclusive_scan.hpp | 3 ++- include/boost/algorithm/cxx17/transform_reduce.hpp | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/boost/algorithm/clamp.hpp b/include/boost/algorithm/clamp.hpp index a179d26..d027acd 100644 --- a/include/boost/algorithm/clamp.hpp +++ b/include/boost/algorithm/clamp.hpp @@ -72,7 +72,7 @@ namespace boost { namespace algorithm { typename boost::mpl::identity::type const & lo, typename boost::mpl::identity::type const & hi ) { - return (clamp) ( val, lo, hi, std::less()); + return boost::algorithm::clamp ( val, lo, hi, std::less()); } /// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out, @@ -93,7 +93,7 @@ namespace boost { namespace algorithm { { // this could also be written with bind and std::transform while ( first != last ) - *out++ = clamp ( *first++, lo, hi ); + *out++ = boost::algorithm::clamp ( *first++, lo, hi ); return out; } @@ -113,7 +113,7 @@ namespace boost { namespace algorithm { typename std::iterator_traits::type>::value_type const & lo, typename std::iterator_traits::type>::value_type const & hi ) { - return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi ); + return boost::algorithm::clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi ); } @@ -139,7 +139,7 @@ namespace boost { namespace algorithm { { // this could also be written with bind and std::transform while ( first != last ) - *out++ = clamp ( *first++, lo, hi, p ); + *out++ = boost::algorithm::clamp ( *first++, lo, hi, p ); return out; } @@ -166,7 +166,7 @@ namespace boost { namespace algorithm { typename std::iterator_traits::type>::value_type const & hi, Pred p ) { - return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi, p ); + return boost::algorithm::clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi, p ); } diff --git a/include/boost/algorithm/cxx17/exclusive_scan.hpp b/include/boost/algorithm/cxx17/exclusive_scan.hpp index 03ecea5..6549db7 100644 --- a/include/boost/algorithm/cxx17/exclusive_scan.hpp +++ b/include/boost/algorithm/cxx17/exclusive_scan.hpp @@ -44,7 +44,7 @@ OutputIterator exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init) { typedef typename std::iterator_traits::value_type VT; - return exclusive_scan(first, last, result, init, std::plus()); + return boost::algorithm::exclusive_scan(first, last, result, init, std::plus()); } }} // namespace boost and algorithm diff --git a/include/boost/algorithm/cxx17/inclusive_scan.hpp b/include/boost/algorithm/cxx17/inclusive_scan.hpp index cd015f1..e16a983 100644 --- a/include/boost/algorithm/cxx17/inclusive_scan.hpp +++ b/include/boost/algorithm/cxx17/inclusive_scan.hpp @@ -41,7 +41,7 @@ OutputIterator inclusive_scan(InputIterator first, InputIterator last, typename std::iterator_traits::value_type init = *first; *result++ = init; if (++first != last) - return inclusive_scan(first, last, result, bOp, init); + return boost::algorithm::inclusive_scan(first, last, result, bOp, init); } return result; @@ -52,7 +52,7 @@ OutputIterator inclusive_scan(InputIterator first, InputIterator last, OutputIterator result) { typedef typename std::iterator_traits::value_type VT; - return inclusive_scan(first, last, result, std::plus()); + return boost::algorithm::inclusive_scan(first, last, result, std::plus()); } }} // namespace boost and algorithm diff --git a/include/boost/algorithm/cxx17/reduce.hpp b/include/boost/algorithm/cxx17/reduce.hpp index f47695b..e5d4942 100644 --- a/include/boost/algorithm/cxx17/reduce.hpp +++ b/include/boost/algorithm/cxx17/reduce.hpp @@ -34,14 +34,14 @@ template T reduce(InputIterator first, InputIterator last, T init) { typedef typename std::iterator_traits::value_type VT; - return reduce(first, last, init, std::plus()); + return boost::algorithm::reduce(first, last, init, std::plus()); } template typename std::iterator_traits::value_type reduce(InputIterator first, InputIterator last) { - return reduce(first, last, + return boost::algorithm::reduce(first, last, typename std::iterator_traits::value_type()); } @@ -49,14 +49,14 @@ template typename boost::range_value::type reduce(const Range &r) { - return reduce(boost::begin(r), boost::end(r)); + return boost::algorithm::reduce(boost::begin(r), boost::end(r)); } // Not sure that this won't be ambiguous (1) template T reduce(const Range &r, T init) { - return reduce(boost::begin (r), boost::end (r), init); + return boost::algorithm::reduce(boost::begin (r), boost::end (r), init); } @@ -64,7 +64,7 @@ T reduce(const Range &r, T init) template T reduce(const Range &r, T init, BinaryOperation bOp) { - return reduce(boost::begin(r), boost::end(r), init, bOp); + return boost::algorithm::reduce(boost::begin(r), boost::end(r), init, bOp); } }} // namespace boost and algorithm diff --git a/include/boost/algorithm/cxx17/transform_inclusive_scan.hpp b/include/boost/algorithm/cxx17/transform_inclusive_scan.hpp index 476c117..f4456d7 100644 --- a/include/boost/algorithm/cxx17/transform_inclusive_scan.hpp +++ b/include/boost/algorithm/cxx17/transform_inclusive_scan.hpp @@ -46,7 +46,8 @@ OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, typename std::iterator_traits::value_type init = uOp(*first); *result++ = init; if (++first != last) - return transform_inclusive_scan(first, last, result, bOp, uOp, init); + return boost::algorithm::transform_inclusive_scan + (first, last, result, bOp, uOp, init); } return result; diff --git a/include/boost/algorithm/cxx17/transform_reduce.hpp b/include/boost/algorithm/cxx17/transform_reduce.hpp index 7ebde7d..fe14d8d 100644 --- a/include/boost/algorithm/cxx17/transform_reduce.hpp +++ b/include/boost/algorithm/cxx17/transform_reduce.hpp @@ -46,7 +46,7 @@ template T transform_reduce(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init) { - return transform_reduce(first1, last1, first2, init, + return boost::algorithm::transform_reduce(first1, last1, first2, init, std::plus(), std::multiplies()); }