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.

This commit is contained in:
Marshall Clow
2018-01-10 10:26:21 -08:00
parent cb52d61054
commit 63c85e7c5e
6 changed files with 16 additions and 15 deletions

View File

@ -72,7 +72,7 @@ namespace boost { namespace algorithm {
typename boost::mpl::identity<T>::type const & lo, typename boost::mpl::identity<T>::type const & lo,
typename boost::mpl::identity<T>::type const & hi ) typename boost::mpl::identity<T>::type const & hi )
{ {
return (clamp) ( val, lo, hi, std::less<T>()); return boost::algorithm::clamp ( val, lo, hi, std::less<T>());
} }
/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out, /// \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 // this could also be written with bind and std::transform
while ( first != last ) while ( first != last )
*out++ = clamp ( *first++, lo, hi ); *out++ = boost::algorithm::clamp ( *first++, lo, hi );
return out; return out;
} }
@ -113,7 +113,7 @@ namespace boost { namespace algorithm {
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo, typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo,
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi ) typename std::iterator_traits<typename boost::range_iterator<const Range>::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 // this could also be written with bind and std::transform
while ( first != last ) while ( first != last )
*out++ = clamp ( *first++, lo, hi, p ); *out++ = boost::algorithm::clamp ( *first++, lo, hi, p );
return out; return out;
} }
@ -166,7 +166,7 @@ namespace boost { namespace algorithm {
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi, typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi,
Pred p ) 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 );
} }

View File

@ -44,7 +44,7 @@ OutputIterator exclusive_scan(InputIterator first, InputIterator last,
OutputIterator result, T init) OutputIterator result, T init)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type VT; typedef typename std::iterator_traits<InputIterator>::value_type VT;
return exclusive_scan(first, last, result, init, std::plus<VT>()); return boost::algorithm::exclusive_scan(first, last, result, init, std::plus<VT>());
} }
}} // namespace boost and algorithm }} // namespace boost and algorithm

View File

@ -41,7 +41,7 @@ OutputIterator inclusive_scan(InputIterator first, InputIterator last,
typename std::iterator_traits<InputIterator>::value_type init = *first; typename std::iterator_traits<InputIterator>::value_type init = *first;
*result++ = init; *result++ = init;
if (++first != last) if (++first != last)
return inclusive_scan(first, last, result, bOp, init); return boost::algorithm::inclusive_scan(first, last, result, bOp, init);
} }
return result; return result;
@ -52,7 +52,7 @@ OutputIterator inclusive_scan(InputIterator first, InputIterator last,
OutputIterator result) OutputIterator result)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type VT; typedef typename std::iterator_traits<InputIterator>::value_type VT;
return inclusive_scan(first, last, result, std::plus<VT>()); return boost::algorithm::inclusive_scan(first, last, result, std::plus<VT>());
} }
}} // namespace boost and algorithm }} // namespace boost and algorithm

View File

@ -34,14 +34,14 @@ template<class InputIterator, class T>
T reduce(InputIterator first, InputIterator last, T init) T reduce(InputIterator first, InputIterator last, T init)
{ {
typedef typename std::iterator_traits<InputIterator>::value_type VT; typedef typename std::iterator_traits<InputIterator>::value_type VT;
return reduce(first, last, init, std::plus<VT>()); return boost::algorithm::reduce(first, last, init, std::plus<VT>());
} }
template<class InputIterator> template<class InputIterator>
typename std::iterator_traits<InputIterator>::value_type typename std::iterator_traits<InputIterator>::value_type
reduce(InputIterator first, InputIterator last) reduce(InputIterator first, InputIterator last)
{ {
return reduce(first, last, return boost::algorithm::reduce(first, last,
typename std::iterator_traits<InputIterator>::value_type()); typename std::iterator_traits<InputIterator>::value_type());
} }
@ -49,14 +49,14 @@ template<class Range>
typename boost::range_value<Range>::type typename boost::range_value<Range>::type
reduce(const Range &r) 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) // Not sure that this won't be ambiguous (1)
template<class Range, class T> template<class Range, class T>
T reduce(const Range &r, T init) 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<class Range, class T, class BinaryOperation> template<class Range, class T, class BinaryOperation>
T reduce(const Range &r, T init, BinaryOperation bOp) 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 }} // namespace boost and algorithm

View File

@ -46,7 +46,8 @@ OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
typename std::iterator_traits<InputIterator>::value_type init = uOp(*first); typename std::iterator_traits<InputIterator>::value_type init = uOp(*first);
*result++ = init; *result++ = init;
if (++first != last) 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; return result;

View File

@ -46,7 +46,7 @@ template<class InputIterator1, class InputIterator2, class T>
T transform_reduce(InputIterator1 first1, InputIterator1 last1, T transform_reduce(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, T init) InputIterator2 first2, T init)
{ {
return transform_reduce(first1, last1, first2, init, return boost::algorithm::transform_reduce(first1, last1, first2, init,
std::plus<T>(), std::multiplies<T>()); std::plus<T>(), std::multiplies<T>());
} }