Skip to main content
2 votes
1 answer
118 views

I have a template wrapper ThreadSafeVar for convenient mutex-locking of variables, and I want to alias std::shared_ptr and std::make_shared so I can do e.g. ThreadSafePtr<int> a = ...
H.v.M.'s user avatar
  • 1,746
1 vote
0 answers
111 views

When i do rosrun i get the error of the title but I'm using smart pointers so I don't know why it appears and I'm not using free or malloc. It's about hole avoidance using a robot. IT receives a point ...
Diego 's user avatar
  • 11
0 votes
1 answer
144 views

It is said that std::make_shared uses ::new, so if any special behavior has been set up using a class-specific operator new, it will differ from std::shared_ptr<T>(new T(args...)). So, given ...
calvin's user avatar
  • 3,135
0 votes
0 answers
51 views

I cannot believe my eyes I've meet this problem that seems to be impossible according to documentation. std::make_shared<USER_TYRE> initializes user type differently from the std::shared_ptr(new ...
Pavlo Tkach's user avatar
1 vote
2 answers
3k views

A sample question on c++ primer: Add member named get_file that returns a shared_ptr to the file in the QueryResult object. class QueryResult { friend std::ostream& print(std::ostream&, ...
gaofeng's user avatar
  • 403
2 votes
2 answers
177 views

From Effective Modern C++, Item 21, I learned that one advantage of std::make_shared over new+std::shared_ptr is that code like this processWidget(std::shared_ptr<Widget>(new Widget), ...
Enlico's user avatar
  • 30.4k
2 votes
2 answers
690 views

From theory, one difference between make_shared() and shared_ptr is the memory allocation technique. make_shared() should use a single block, while shared_ptr should use two blocks. One make_shared() ...
Fzza's user avatar
  • 123
0 votes
1 answer
84 views

#include <iostream> #include <memory> using namespace std; struct buffer{ int buffFilled; }; struct verifyStruct{ int capacity; int size; std::shared_ptr&...
preethi selvaraju's user avatar
0 votes
2 answers
243 views

My question is: is there a case that share_ptr ref count is 0, while weak_ptr ref count is not 0? Difference in make_shared and normal shared_ptr in C++ Referr this thread, showing that if a ...
Troskyvs's user avatar
  • 8,307
0 votes
1 answer
277 views

I have some code : #include <list> #include <iostream> #include <string> class A { private: std::string field1; std::string field2; public : ...
Ioan Le Gué's user avatar
0 votes
1 answer
334 views

I have a template function, that should get std::shared_ptr<sometype>. Inside of function I want to make a temporary variable with std::shared_ptr<sometype>, but I can't put sometype as ...
mouse_00's user avatar
  • 693
1 vote
3 answers
240 views

Consider this piece of code creating, based on a condition, a different class instance through a std::make_shared. Note that the two possible classes used (Child1 and Child2) are having the same ...
jpo38's user avatar
  • 21.9k
1 vote
1 answer
509 views

Compiling with -std=c++14 the following code: #include <memory> class A { public: static constexpr int c = 0; std::shared_ptr<int> b; A() { b = std::make_shared&...
Nicola Lissandrini's user avatar
1 vote
0 answers
191 views

I'm using C++17 and stumbled on a linker error with this kind of code #include <memory> struct SomeType { static const int MIN = 0; static const int MAX = 0; }; struct Range { ...
Allan Ojala's user avatar
3 votes
1 answer
154 views

I've wrote a shared_ptr the class definition is as below: template <typename T> class shared_ptr { private: ... public: shared_ptr(T* p); shared_ptr(shared_ptr& src); shared_ptr& ...
Pan's user avatar
  • 155

15 30 50 per page
1
2 3 4 5
10