shared_ptr
is not thread-safe, as in accessing the same instance from multiple threads is not allowed. However, using two different instances of shared_ptr
that both point to the same object is thread-safe, as long as that object itself is thread-safe. See also the documentation
So if you store the shared_ptr
as a reference in Class
, that might crash. Make a copy of the shared_ptr
instead.