Hans-J. Schmid (16) [Avatar] Offline
Could not find moving_accumulate as advertised in chapter 2. Is it missing or am I just blind?

Kind regards,
Ivan Cukic (96) [Avatar] Offline
It is currently not in the gitlab - it will be before the book goes to print.

For the time being, this is the moving accumulate:

// A modified implementation of std::accumulate which avoids                    
// unnecessary copies -- whenever it calls the folding function,                
// it moves the previously accumulated value into it instead                    
// of passing a copy                                                            
template <typename BeginIt, typename EndIt, typename T, typename F>             
T moving_accumulate(BeginIt first, const EndIt& last, T init,                   
                    F folding_function)                                         
    for (; first != last; ++first) {                                            
        // When passing the accumulated value to                                
        // the folding function, move from it.                                  
        // This might make problems for types that                              
        // do not support assignment to moved-from values,                      
        // but it will work for most types without problems.                    
        init = folding_function(std::move(init), *first);                       
    return init;                                                                
Hans-J. Schmid (16) [Avatar] Offline
Thanks a lot, Ivan!!!