title: Splitting std::vector based on some criteria
body: <p>I have a vector which contain some data. I want to split it into const number of vectors depending on some criteria. For example:</p>
  
  <pre><code>using Point=std::pair&lt;int,int&gt;;
  std::array&lt;std::vector&lt;Point&gt;,4&gt; split_to_4(const std::vector&lt;Point&gt;&amp; data,std::function&lt;size_t(Point)&gt; criteria);
  int main(){
      std::vector&lt;Point&gt; data;
      //fill data
      auto results=split_to_4(data,[](const Point&amp; p){
          if(cond1) return 0;
          if(cond2) return 1;
          if(cond3) return 2;
          return 3;
      });
  }
  </code></pre>
  
  <p>What is the best way to implement <code>split_to_4</code>? My current attempt is:</p>
  
  <pre><code>std::array&lt;std::vector&lt;Point&gt;,4&gt; split_to_4(const std::vector&lt;Point&gt;&amp; data,std::function&lt;size_t(Point)&gt; criteria){
      std::array&lt;std::vector&lt;Point&gt;,4&gt; result;
      for (const auto&amp; p : data){
          areas_regions[criteria(p)].emplace_back(p);
      }
      return result;
  }
  </code></pre>
  
  <p>Any better.. More <code>std</code> way to do it?</p>
  
  <p>By Better, I mean: more readable... depend on iterator... depend on some std functions...</p>