Skip to content

Commit

Permalink
add std:: to "inner_product" and "accumulate"
Browse files Browse the repository at this point in the history
This only works because the "dot" function is always called with std::vector<T>::iterator as input so that "argument dependent lookup" introduces the std namespace to the function. If the dot function is called like this "dot(v.data(), v.data()+v.size(), v.data())", where "v" is a std::vector and the input are plain pointers, the compiler will not find "inner_product". The same is true for the use of "accumulate".
  • Loading branch information
g3bk47 authored and speth committed Sep 14, 2018
1 parent b0b66d7 commit 1166c74
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/cantera/base/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ template<class InputIter, class InputIter2>
inline doublereal dot(InputIter x_begin, InputIter x_end,
InputIter2 y_begin)
{
return inner_product(x_begin, x_end, y_begin, 0.0);
return std::inner_product(x_begin, x_end, y_begin, 0.0);
}

//! Multiply elements of an array by a scale factor.
Expand Down Expand Up @@ -234,7 +234,7 @@ template<class InputIter, class OutputIter>
inline void normalize(InputIter begin, InputIter end,
OutputIter out)
{
doublereal sum = accumulate(begin, end, 0.0);
doublereal sum = std::accumulate(begin, end, 0.0);
for (; begin != end; ++begin, ++out) {
*out = *begin/sum;
}
Expand Down

0 comments on commit 1166c74

Please sign in to comment.