Boost logo

Boost Users :

Subject: Re: [Boost-users] [bind] counterintuitive behavior with vector and auto_ptr
From: Christian Henning (chhenning_at_[hidden])
Date: 2010-06-13 02:09:59


Thanks all. I can now see that the auto_ptr::get() doesn't throw but
auto_ptr::operator->() does, although it's labeled as throw(). It only
throws in debug mode, anyway.

Thanks again,
Christian

On Fri, Jun 11, 2010 at 11:12 PM, <Tiemo.Jung_at_[hidden]> wrote:
> Hi,
>
> the reason why the for_each loop works, boost::bind unwraps the auto_ptr
> with get(), and get() does not trigger a debug break, but the operator ->
> does, so your other calls trigger a breakpoint (on release build this will
> be disabled and all test will pass). And the boost bind call of A::foo
> does not crash, because it does not touches 'this' of the object (the bind
> call uses the static address of A::foo and not the vtable of A).
>
> TJ.
>
> Am 12.06.2010, 08:41 Uhr, hast Du in gmane.comp.lib.boost.user geschrieben:
>
>> Hi there,
>>
> <---Schnitt--->
>>>
>>> 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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