Is it possible to rewrite this as a one liner?
<p>This is actual code.Here I am calling for_each to carry out the function shown in sum.Can this be reduced to writing the function inside the for_each statement itself?</p>

<pre><code>int S;
struct sum
{
 sum(int&amp; v): value(v){}
 void operator()(int data)const {value+=(int)((data+(data%S==0?0:S))/S)+2;}
 int&amp; value;
};
int main()
{
  int cnt=0;
  S=5;
  for_each(flights.begin(),flights.end(),sum(cnt));
  cout&lt;&lt;cnt-2;
  return 0;
}
</code></pre>
