简体   繁体   English

如何从boost库中取出单个元素(例如shared_pointer)?

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

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 . 我一直在玩一些Boost组件,我正在研究的项目中我唯一看到的就是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? 难道只是包含shared_ptr所需的文件,或者至少只包含我项目中Boost smart_ptr目录的文件? 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. 他们似乎对Boost的其他部分有一些外部依赖 - 但我认为有一种简单的方法来使用Boost库的某些组件而我却错过了它。

If you can tell me what parts I need or point me to a good tutorial I'd be most grateful! 如果你能告诉我我需要哪些部件或者给我一个好的教程,我将非常感激!

You can use the bcp tool to extract only the header you want. 您可以使用bcp工具仅提取所需的标头。

bcp shared_ptr /foo

This copies shared_ptr and all dependencies to the directory foo shared_ptr和所有依赖项复制到目录foo

You can only include the shared_ptr headers from boost like this 您只能像这样包含boost中的shared_ptr标头

#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) 你可以用这种方式包含boost lib的几乎每个部分,它几乎没有进一步的依赖(只适用于一些更复杂的库)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM