Yes, I use Boost libraries for Qt applications.
Yes, I do, but only for non-Qt applications.
No, I don't use them at all.
So Boost pointers won't do that for you:
Right?. I have 'played' with it in the past and used mainly the smart pointers as I often forget to delete pointers and using these, it does it for you.
So is there a pointer in the family that deletes objects pointed to when it's deleted but doesn't hijack the object (for me this is contradictory, but maybe I just can't imagine the situation)?
Boost has three kinds of smart pointers:
- shared pointers, which share the ownership amongs them,
- scoped pointers, which take the ownership for themselves,
- weak pointers, which don't take the ownership, but know when the object was destroyed.
All these three kinds of smart pointers are well behaved and the term "hijacking" isn't appropriate. It's just as if you said that QCoreApplication::postEvent() "hijacks" pointers, because it takes their ownership --- it doesn't, it's just a part of its contract.
If you want to call something "pointer hijacking", take a look what std::auto_ptrs do on copy --- they're like hungry hienas, which steal a dead antilope from each other.
So "weak pointer" is an equivalent of QPointer, "scoped pointer" does to pointers more or less what QMutexLocker does to mutexes and shared pointer is a combination of the two that does reference counting. Correct? Of course all these might fail if you use any regular pointers with the same object.
What I've tried from boost yet was just great. If you need to do parsing: Have a look at Boost.Spirit. It uses TMP (template meta programming) and gives C++ a completely new dimension![]()
Bookmarks