首页 > 解决方案 > Please help me to understand boost::make_shared

问题描述

I am self-learning C++ and have got a piece of C++ code which reads like:

boost::make_shared<Something<Some_Other_thing> >()

I failed to comprehend what the above line is doing and why it may be required.

What would be an alternative way to achieve the same?

Could you please help me to understand in relatively simple language?

Any pointer will be highly appreciated.

标签: c++pointersboostmake-shared

解决方案


通过调用该函数,您正在创建指向 Something<Some_Other_thing> 类型的共享指针。共享智能指针用于管理资源,当没有更多变量持有该指针时,资源被删除。更多信息在这里这里


推荐阅读