Consider this code:
#include
#include
class SomeClass {
public:
SomeClass() {
std::cout << \"SomeClass()\" &l
To expand on Mat's correct answer, make_shared
is typically implemented by allocating an object that contains the shared_ptr
reference counts and a buffer of uninitialized bytes:
template
struct shared_count_inplace
{
long m_count;
long weak_count;
typename std::aligned_storage::type m_storage;
// ...
};
This is the type which will be allocated on the heap, not your type, so your type's new
is not called. Then your type will be constructed using placement new
at the location (void*)&m_storage
.