#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <ciso646>

using namespace std;

// Possible implementation from http://e...content-available-to-author-only...e.com/w/cpp/algorithm/find
template<class InputIt, class T>
InputIt my_find(InputIt first, InputIt last, const T& value)
{
  for (; first != last; ++first)
    if (*first == value)
      return first;
  return last;
}

int main() {
  vector<bool> b(5,false);

#ifdef _LIBCPP_VERSION
  cout << "_LIBCPP_VERSION=" << _LIBCPP_VERSION << endl;    // 1101 <-> XCode 4.6.3
#endif

  // show - lambda to show distance of b.begin()->it, it->b.end()
  auto show = [&](vector<bool>::iterator it)
  { cout << distance(b.begin(), it) << "," << distance(it,b.end()) << endl; };

  show(b.begin());                                  // shows 0,5 as expected
  show(b.end());                                    // shows 5,0 as expected
  show(find(next(b.begin(), 1), b.end(), true));    // shows 64/-59! should be (5,0)
  show(my_find(next(b.begin(), 1), b.end(), true)); // shows 5,0 as expected

  return 0;
}