简体   繁体   中英

Using boost shared_ptr

I have to use a smart pointer and I found "shared_ptr" from boost looks good. I downloaded the boost library and I can see many files and libraries there. Is there any way to use only the shared_ptr ?

boost bcp is your friend. It allows extracting individual boost libraries out of its tree. I used it with success in the past. shared_ptr consists only of headers, so that will be especially good for you.

You can use bcp as litb suggested, but if you're worried about dragging in extra library code, you shouldn't be. Boost, in general, follows the C++ philosophy of "you only pay for what you use". So, if you include only the shared_ptr headers, that's all that your code will use.

If you're using a recent version of Visual C++ on Windows, BoostPro provides a convenient free installer here: http://www.boostpro.com/products/free .

Otherwise, or if you have already downloaded the source distribution, you should in fact be able to start using shared_ptr and friends right away as the shared_ptr library is "header-only" -- no compilation of .cpp files is required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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