On 10/13/2016 1:36 PM, Daniela Engert wrote:
Am 13.10.2016 um 00:58 schrieb Edward Diener:
You are designing or working on a library, perhaps for Boost, perhaps for fun, and part of the design of the library has some public functionality taking a shared pointer as input. You:
2) Use std::shared_ptr
For libraries that are consumed only within our company, std::shared_pointer ist the most convenient option. Our baseline compiler is vc12 with some older stuff in maintenance mode still on vc10, so std::shared_ptr is viable. Typically the pointer type is typedef'd in some way for user convenience.
Makes perfect sense. It certainly helps when you know exactly in what environment the library you create will be used.
4) Use neither, you roll your own shared pointer-like functionality
The last library that I designed also for use by external customers, I rolled my own 'handle' type which is completely opaque to users which see just a struct with no more than one single uintptr_t member. Under the covers it is a boost::intrusive_ptr. The idea is to prevent accidental misuse and not to force users taking a dependency on boost. The library itself is taking advantage of any boost functionality it sees fit.
OK, thanks ! I assume that actual implementation code for your opaque type is in the built portion of a non header-only library.
Hope this helps Dani