smart-pointers
enable_shared_from_this - empty internal weak pointer?
I\'m using enable_shared_from_this<Base> and then inherit from Base. When trying to use 开发者_开发技巧shared_from_this() in Derived\'s constructor (not initializer list), I get an exception. Tu[详细]
2023-02-01 01:05 分类:问答enable_shared_from_this and inheritance
I\'ve got a type which inherits from enable_shared_from_this<type>, and another type that inherits from this type. Now I can\'t use the shared_from_this method because it returns the base type a[详细]
2023-01-31 17:08 分类:问答shared_ptr coexisting with pointers
I have a function as follows void a(shared_ptr<X> val) {...} Sometimes, I want to pass in a heap-allocated object[详细]
2023-01-31 16:00 分类:问答weak_ptr and parent-child cyclic dependencies
I currently have something similar to the following: class Parent { //just a single child... for sake of simplicity[详细]
2023-01-31 08:53 分类:问答Manual Object Ownership vs Smart Pointers
Right now, object ownership/deletion in my C++ project is manually tracked (via comments mostly). Almost every heap allocated object is created using a factory of sorts[详细]
2023-01-31 06:27 分类:问答Can I write a C++ functor that accepts both a raw pointer and a smart pointer?
Given the following: struct Foo { int bar() const; }; struct IsEqual : public std::unary_function<Foo*, bool>[详细]
2023-01-30 14:47 分类:问答Best practice for std::auto_ptr
I\'m just getting used to smart pointers using std::auto_ptr. Assume that I want to call a function with both auto_ptr and normal Pointers.[详细]
2023-01-30 13:59 分类:问答auto-instantiated smart pointer
I am looking for a simple way to reduce header coupling in a C++ project, which comes mostly due to (overused) class composition which of course requires complete type. For example:[详细]
2023-01-30 13:09 分类:问答enable_shared_from_this (c++0x): what am I doing wrong?
I\'m just toying around with the smart pointers in the upcoming new c++ standard. However I fail to grasp the usage of the shared_from_this function. Here is what I have:[详细]
2023-01-30 12:07 分类:问答How to manage shared_ptr that points to internal data of already referenced object?
Suppose I have these classes: struct Engine { int engine_data; }; struct Car { shared_ptr<Engine> engine;[详细]
2023-01-30 06:23 分类:问答