Skip to content

Commit 5165ba9

Browse files
committed
take functor by value and return it
1 parent 211bc83 commit 5165ba9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

examples/boost-simd-for-each.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class Accumulator
2828
// [[Rcpp::export]]
2929
double vectorProd(NumericVector x) {
3030
auto accumulator = Accumulator();
31-
boost::simd::for_each(x.begin(), x.end(), accumulator);
32-
return accumulator;
31+
return boost::simd::for_each(x.begin(), x.end(), accumulator);
3332
}
3433

3534
/*** R

inst/include/RcppParallel/simd/for_each.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace boost {
55
namespace simd {
66

77
template <typename T, typename F>
8-
void for_each(const T* it, const T* end, F& f)
8+
F for_each(const T* it, const T* end, F f)
99
{
1010
typedef boost::simd::pack<T> vT;
1111
static const std::size_t N = vT::static_size;
@@ -20,6 +20,8 @@ void for_each(const T* it, const T* end, F& f)
2020

2121
for (; it != end; ++it)
2222
f(*it);
23+
24+
return f;
2325
}
2426

2527
} // namespace simd

0 commit comments

Comments
 (0)