FAQ Database Discussion Community

Constructor taking shared_ptr

I have situation like this struct Foo { Foo(int x, int y) : x(x), y(y) { } int x, y; }; class Bar { public: typedef std::shared_ptr<const Foo> ConstFooPtr; typedef std::shared_ptr<Foo> FooPtr; Bar(int index = 0, FooPtr ptr = FooPtr()) : index_(index), ptr_(ptr) { } private: ConstFooPtr ptr_; int index_;...

std::shared_ptr(new DerivedType(…)) != std::make_shared(DerivedType(…))?

I haven't found any issues quite like this yet: but if someone finds one then sorry. I've been trying to use std::shared_ptr to greatly simplify memory management, however I've come across what must be some sort of bug. When I create a DerivedType pointer with std::make_shared<type>(DerivedType(...)) It can only be...