Boost logo

Boost Users :

Subject: Re: [Boost-users] Avoiding reinventing the wheel for a public api with binary compatibility in mind
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-11-04 20:27:07


On Wed, Nov 4, 2009 at 5:16 PM, Geoff Hilton
<geoff.hilton_at_[hidden]> wrote:

> Using boost::shared_ptr would be great, but this means clients of my code
> would have to have the same version of boost installed that we use, and I
> imagine this could cause conflicts in the event that they happen to use
> boost (and a different version of it).

In theory, yes, they must use the same version of boost. In practice,
you'll be surprised how resilient shared_ptr is to breaking binary
compatibility across boost versions.

That said, if you want to be bullet-proof, you can do pimpl the old fashion way:

struct foo;
foo * create_foo(....);
void destroy_foo( foo * );
void use_foo( foo * );

Note that users can still easily use shared_ptr:

boost::shared_ptr<foo> x(create_foo(....),destroy_foo);

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net