Use of observer_ptr

The proposal makes it pretty clear that it’s just for self-documentation: This paper proposes observer_ptr, a (not very) smart pointer type that takes no ownership responsibility for its pointees, i.e., for the objects it observes. As such, it is intended as a near drop-in replacement for raw pointer types, with the advantage that, as a … Read more

Can Google Mock a method with a smart pointer return type?

A feasible workaround for google mock framework’s problems with non (const) copyable function arguments and retun values is to use proxy mock methods. Suppose you have the following interface definition (if it’s good style to use std::unique_ptr in this way seems to be more or less a philosophical question, I personally like it to enforce … Read more

smart pointers and arrays

It will call delete[] and hence the entire array will be reclaimed but I believe you need to indicate that you are using an array form of unique_ptrby: std::unique_ptr<int[]> my_array(new int[5]); This is called as Partial Specialization of the unique_ptr.

Getting a normal ptr from boost::shared_ptr?

Use the get() method: boost::shared_ptr<foo> foo_ptr(new foo()); foo *raw_foo = foo_ptr.get(); c_library_function(raw_foo); Make sure that your shared_ptr doesn’t go out of scope before the library function is done with it — otherwise badness could result, since the library may try to do something with the pointer after it’s been deleted. Be especially careful if the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)