|
Boost Users : |
Subject: Re: [Boost-users] [bind] counterintuitive behavior with vector and auto_ptr
From: Christian Henning (chhenning_at_[hidden])
Date: 2010-06-12 02:41:45
Hi there,
>> Basically, I have a vector of auto_ptrs which is copied into a second
>> vector, thus the first vector's auto_ptr loss their resource and point
>> to nowhere. Basic stuff, as I said. Now, when I try to use an auto_ptr
>> from the first vector using boost::bind everything still works.
>> Meaning the code doesn't fail, although it should. I find that
>> surprising. Why is boost::bind recreating the resource?
>>
>
> It isn't. Boost.Bind passes the arguments by reference, so
> the auto_ptr is never copied.
All auto_ptrs have been copied a couple of lines before. See the
std::copy call. After that my debugger tells me that all auto_ptrs are
empty which makes sense. Still not clear to me what exactly happens
when using bind.
Christian
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