```cpp
DoubleReal accumulate_helper(DoubleReal res, std::pair<DoubleReal, DoubleReal> in)
{
  return res + in.second;
}
```
combined with 

```
DoubleReal sum = std::accumulate(&totals[LEN], &totals[2 * LEN], 0.0, accumulate_helper);
```

does the trick.