参考: std::enable_shared_from_this - cppreference.comen.cppreference.com/w/cpp/memory/enable_shared_from_this 有: CMakeLists.txt cmake_minimum_required(VERSION 3.20) project ( testprj ) set ( PRJ_COMPILE_FEAT
C 内存管理库 低层内存管理 std::pmr::memory_resource std::allocator std::pointer_traits std::enable_shared_from_this<T>::weak_from_this std::default_delete std::allocator_arg_t std::allocator_arg std::bad_weak_ptr std::uses_allocator std::uses_allocator_construction_args std::uninitialize...
传递shared_ptr 指针时,如果临时以祼指针传递,容易造成共享关系的断裂,this 也是裸指针,所以,当需要在 class 内部,将 this 以 shared_ptr<T> 的方式传递时,你就需要 std::enabled_shared_from_this。 问题 这是boost里面举的一个例子:class Y: public...