Sum:@structtype={operator():(inoutthis,n:int)={sum+=n;}sum:int=0;}main:()={v:std::vector=(3,-4,2,-8,15,267);printer:=:(n:int)={std::cout<<"(n)$ ";};std::cout<<"before:\t";std::for_each(v.cbegin(),v.cend(),printer);std::cout<<'\n';// increment elements in-placestd::for_each(v.begin(),v.end(),:(inoutn)=n++);std::cout<<"after:\t";std::for_each(v.cbegin(),v.cend(),printer);std::cout<<'\n';// invoke Sum::operator() for each elements:Sum=std::for_each(v.cbegin(),v.cend(),Sum());std::cout<<"sum:\t(s.sum)$\n";}