Boost logo

Boost :

From: Dirk Gerrits (dirkg_at_[hidden])
Date: 2002-05-16 11:39:08


> One night while trying to fall asleep my mind drifted to
> this problem (yeah, I know what that says about me),

It merely says that you're a programmer. :)

> However, there are issues with "move semantics" that have
> caused a lot of questions about how to use std::auto_ptr<>
> correctly, and these issues would exist here as well.

I'm not 100% sure exactly which issues you mean. Surely, the
issue that auto_ptrs can't be used in containers is not
relevant here. ;)

But 'pass by value acts like a sink' does apply here right?

void func(auto_ptr ptr) {};
{
    // code here
} // ptr's value is destroyed [mutex is unlocked]

int main()
{
    auto_ptr<int> ptr(new int(0));
    // use ptr here, no problemo [use locked object]
   
    func(ptr);

    // use ptr again (as a null pointer!) [use object, now unlocked!]

} // destructor is now a no-op

I can see this would be problematic. But what other issues are
you referring to?

Dirk Gerrits


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk