Consider this code:
#include
#include
class SomeClass {
public:
SomeClass() {
std::cout << \"SomeClass()\" &l
Yes, this is standard behavior. From the standard (§20.7.2.2.6 shared_ptr creation ):
Effects: Allocates memory suitable for an object of type T and constructs an object in that memory via the placement new expression
::new (pv) T(std::forward
(args)...).
This allows make_shared
to allocate the storage for both the object and the data structure for the shared pointer itself (the "control block") in a single allocation, for efficiency reasons.
You could use std::allocate_shared if you want to control that storage allocation.