Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-09-12 15:35:16


From: "Mark Snelling" <mark_at_[hidden]>
> Ok, I understand the following:
>
std::for_each(mylist.begin(),mylist.end(),boost::checked_deleter<Object>());
>
> But when I try to use the boost::checked_deleter on the objects held in
> a map using your solution to my first problem I don't seem to be able to
> get it to compile:
>
> template<class It, class F> void for_each_pair(It first, It last, F f)
> {
> for(; first != last; ++first)
> {
> f(first->first, first->second);
> }
> }
>
> int main()
> {
> std::map<int, Block*> blocks;
> std::for_each_pair(blocks.begin(), blocks.end(),
> boost::bind(boost::checked_delete<Block>(), _2));
> }

checked_delete is a function template (no trailing 'r'); checked_deleter is
a class template. :-)

Also, on MSVC 6/7 you need to specify a return type when binding general
function objects:

boost::bind<void>(boost::checked_deleter<Block>(), _2)


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