Template:cpp/memory/shared ptr/enabling shared from this

A constructor enables  with a pointer of type  means that it determines if  has an  base class that is a specialization of std, and if so, the constructor evaluates the statement:

Where is the hidden mutable std member of std. The assignment to the member is not atomic and conflicts with any potentially concurrent access to the same object. This ensures that future calls to would share ownership with the std created by this raw pointer constructor.

The test in the exposition code above makes sure that  is not reassigned if it already indicates an owner. This test is required as of C++17.