|
Boost Users : |
Subject: [Boost-users] Boost.lambda: can I do this with a lambda function (multiplestatements?
From: Joost Kraaijeveld (J.Kraaijeveld_at_[hidden])
Date: 2009-02-03 13:31:01
Hi,
I want to embed some debug printing in a lambda function which is a
predicate used to remove elements from a vector like this:
collection.erase( std::remove_if(
collection.begin(),
collection.end(),
boost::lambda::if_then_else_return(
boost::lambda::_1 <= "s5", // if
(std::cout << "deleted: " << boost::lambda::_1, true), // then
(std::cout << "not deleted: " << boost::lambda::_1, false ))), // else
collection.end());
This actually compiles, runs and removes all the right elements but it
does not print for every element it is checking.
It just prints "not deleted: deleted: s4s5s6s8" , the last string being
all the elements of the collection.
Is what I want possible and if so how?
TIA,
-- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 web: www.askesis.nl
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net