class Node{public: Node *child(int index) { return _children.at(index).get(); }private: std::vector<std::unique_ptr<Node>> _children;};
_children.push_back(new Node); // oooops!
C++ (Qt)void SomeClass::someMethod( SomeObject * object_ptr ){ if ( object_ptr != nullptr ) { SomeObject & object = *object_ptr; object.doSomething(); }}
C++ (Qt)void SomeClass::someMethod( weak_ptr< SomeObject > object_weak ){ shared_ptr< SomeObject > object_guard = object_weak.lock(); if ( object_guard ) { SomeObject & object = *object_guard; object.doSomething(); }}
C++ (Qt)void SomeClass::someMethod( weak_ptr< SomeObject > object_weak )...
C++ (Qt)void SomeClass::someMethod( void ){ shared_ptr< SomeObject > guard = m_object_weak.lock(); // член m_object_weak if (guard) { ... } else { // И здесь что ??? }}
C++ (Qt)struct SomeClass { ... shared_ptr<SomeData> m_data; ...};
C++ (Qt)struct SomeClass { ... SomeData *m_data; ...};
C++ (Qt)struct SomeClass { ... SomeData *data() const; ...};