gsf
gsf

Reputation: 7232

can I build boost libraries with std::shared_ptr instead of boost::shared_ptr

In c++11 project I would like to use as much as possible stl primitives instead the boost ones. I though still need some of the boost libraries - for example filesystem. It though uses boost::shared_ptr.

My question is - is there a way to make boost to switch to using std::shared_ptr and how?

Upvotes: 2

Views: 263

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473302

Does Boost have a configuration setting to make it use std::shared_ptr? Not generally. Boost.Asio apparently has a way to make the internals use std::shared_ptr (which seems to turn on automatically when std::shared_ptr is available). But there is no Boost-wide setting for this.

You could probably do some find-replace gymnastics to make it work. Of course, that assumes that none of those Boost libraries are making assumptions about Boost's internals. And that none of them have access to its internals. And that boost::shared_ptr has no interface differences from std::shared_ptr.

It's not going to be worth the effort. Let Boost use whatever code it wants to internally. The only place where it should matter to you is in interfaces, and very few Boost libraries actually use boost::shared_ptr in an interface to your code. Indeed, I did a Google site search for std::shared_ptr on the Boost 1.59 documentation, and the only place that I found that it was even referenced was in the document I linked above.

Upvotes: 2

Related Questions