Christopher Smith on Mon, 22 Mar 2004 19:03:02 -0600 (CST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [ALACPP] copy_if? |
Okay, new wrinkle here. At lunch, John pointed me to: std::replace_copy_if() as the hackish-but-workable solution to my copy_if function. So, I quickly hacked this up: template<typename InputIterator, typename OutputIterator, typename Predicate> inline OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred) { return std::remove_copy_if(first, last, result, boost::not1(pred)); } Here's the funny thing. This works if I invoke it with: copy_if(temp.begin(), temp.end(), ostream_iterator<string>(cout, "\n"), sillyUnaryFunction); But it fails with: copy_if(temp.begin(), temp.end(), ostream_iterator<string>(cout, "\n"), boost:bind(sillyBinaryFunction, _1 value)); Seems like a classic case of boost's funky type theory killing me. I have yet to figure out the exact nature of the problem. It's worth noting that my original implementation handed both cases with aplomb. Not sure if std::remove_copy_if() is a net win really. --Chris _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp