title: Convenient way to return filtered collection
body: <h3>Problem</h3>
  
  <p>Suppose I have two iterators <code>begin</code> and <code>end</code> of type Iterator and some predicate <code>predicate</code> (stored in <code>obj</code>). I want to implement method <code>some_collection()</code> o that I can write</p>
  
  <pre><code>for(auto element: obj.get_collection()) {
      do_smth()
  }
  </code></pre>
  
  <p>so that it's work only on elements which satisfy predicate (i.e eqiuvalent to smth like this)</p>
  
  <pre><code>for (auto element: range(begin, end)) {
      if (predicate(element)) {
          do_smth();
      }
  }
  </code></pre>
  
  <h3>My solution</h3>
  
  <p>Approximate implementation I have in mind is the following (pseudocode):</p>
  
  <pre><code>struct Wrapper {
      op++() {
          do {
             ++value;
          while (!predicate(*value));
      }
      op*() {
          return *value;
      }
      op !=(Iterator other) {
          return value != other.value;
      }
      Iterator value;
  }
  </code></pre>
  
  <p>Where <code>begin()</code> of returned object will be like</p>
  
  <pre><code>value = begin;
  while (!predicate(*value)) ++value;
  return Wrapper(value)
  </code></pre>
  
  <p>and <code>end()</code> is just <code>Wrapper(end)</code></p>
  
  <h3>Caveats</h3>
  
  <p>What I don't like in this implementation:</p>
  
  <ul>
  <li>Wordiness: I just need to filter, and have to write ton of code</li>
  <li>Initialisation is kind of ugly - have to increment right there</li>
  <li>If I won't iterate over all objects (will break or just don't use any values) I'll iterate extra (to the next unused element)</li>
  </ul>
  
  <p>I could iterate before each dereference (to fix 2nd and 3rd points) but it will make <code>!= end</code> check harder (either I need to decrement end in advance or use increment in check itself which means passing input range two times during the cycle)</p>
  
  <h3>Requirements</h3>
  
  <p>I don't have specific language version requirements and even interested in implementations using not yet approved. But C++11 would be the greatest</p>
  
  <p>I don't have specific requirements for iterator category supported. I believe Mine will work with <code>ForwardIterators</code>.</p>
  
  <p>I'm interested in both understandability of the code and its efficiency.</p>
  
  <p>Any solution that is closer to silver bullet? :)</p>