

#include <iostream>

// copy elements in range starting at start to out
// until endCond(start) is true.
template <typename II, typename Pred, typename OI>
OI copy_until(II start, Pred endCond, OI out)
{
  while (! endCond(start))
    *out++ = *start++;
  return out;
}

// example use

template <typename Iter>
bool pointsToNull(Iter i)
{
  return !(*i);
}

int main()
{
  using std::cout;
  using std::ostream_iterator;
  using std::cin;
  using std::ws;
  const char *s = "this is a test";
  copy_until(s, pointsToNull<const char *>, ostream_iterator<char>(cout, " "));
  cin >> ws;
}
