The idiomatic way would be:
auto accumulation = std::accumulate(m.begin(), m.end(), 1, std::multiplies{});
Your func
does a lot of odd stuff and I have no idea what you hope for with accumulation = a * *m.begin()++;
or why you leave i
unused. This would be more like it:
auto func = [](int lhs, int rhs) { return lhs * rhs; };
auto accumulation = std::accumulate(m.begin(), m.end(), 1, func);
Or if you want to do it with float
s:
auto func = [](float lhs, float rhs) { return lhs * rhs; };
auto accumulation = accumulate(m.cbegin(), m.cend(), 1.f, func);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…