Sumant Tambe (17) [Avatar] Offline
#1
Chapter 2, section 2.2.2: It may be worthwhile to discuss the guarantees of std::accumulate makes regarding making copies of the intermediate result in to the user-supplied function. I checked that std::accumulate requires that init value type be copy-assignable and copy-constructible. However, it looks like std::accumulate can be used to avoid copies either by returning a reference or by using std::ref and std::reference_wrapper.

I’ve not looked at moving_accumulate at the time of this writing.