How can I take a single element out of a boost library (e.g. shared_pointer)?

我是研究僧i 提交于 2020-01-01 09:34:07

问题


I've been playing around with some Boost components, and the only one I see a direct need for in the project I'm working on is boost::shared_ptr.

Would it be difficult to just include the required files for shared_ptr, or at least just include files for the Boost smart_ptr directory in my project? They seem to have some external dependencies on other parts of Boost - but I figure there's an easy way to just use certain components of the Boost library and I'm missing it.

If you can tell me what parts I need or point me to a good tutorial I'd be most grateful!


回答1:


You can use the bcp tool to extract only the header you want.

bcp shared_ptr /foo

This copies shared_ptr and all dependencies to the directory foo




回答2:


You can only include the shared_ptr headers from boost like this

#include <boost/shared_ptr.hpp>

look at a basic example here or for more examples here

you can include nearly every part of the boost lib in this way and it has nearly no further dependencies (only for some more complex libs)



来源:https://stackoverflow.com/questions/7693315/how-can-i-take-a-single-element-out-of-a-boost-library-e-g-shared-pointer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!