6
std :: shared_ptr <void>が機能する理由
シャットダウン時にstd :: shared_ptrを使用して任意のクリーンアップを実行するコードを見つけました。最初はこのコードは機能しないと思っていましたが、次のことを試しました。 #include <memory> #include <iostream> #include <vector> class test { public: test() { std::cout << "Test created" << std::endl; } ~test() { std::cout << "Test destroyed" << std::endl; } }; int main() { std::cout << "At begin of main.\ncreating std::vector<std::shared_ptr<void>>" << std::endl; std::vector<std::shared_ptr<void>> v; { std::cout << "Creating …
129
c++
c++11
shared-ptr