
On Sat, May 15, 2010 at 10:53 AM, Artyom <artyomtnk@yahoo.com> wrote:
OK, can I so something like the following?
boost::shared_ptr<int> a(new int(0)); booster::shared_ptr<int> b = a;
(replace shared_ptr with all the other boost-look-alike classes)
No you can't assign boost::shared_ptr to booster::shared_ptr as you can't assign std::tr1::shared_ptr to boost::shared_ptr
But you can freely replace one with other as long as they consistent.
But that could then ripple through an entire codebase - 100Ks, most of it not mine to change. What might, instead, be possible is to make some bridge classes. library.h: inline boost::shared_ptr<int> some_api() { boost::abi::shared_ptr<int> asp = some_api_abi(); // call the real function return boost::shared_ptr<int>(asp, boost::abi::deleter<int>); } ***Or something like that*** Importantly, note that since this is in your h file, which I include, I will get *my* version of shared_ptr returned from some_api(). It will be a wrapper around your shared_ptr, thus with extra overhead, but at least it will work. Basically your functions return a abi version of shared_ptr, which may need to be pure interface, if you really want to be sure about abi: template <typename T> struct boost::abi::shared_ptr { virtual void delete() = 0; virtual void add_ref() = 0; //... }; Or maybe it is something else, but it is a simple bridge that you can hopefully keep compatible for a number of years, and can be converted to *my* shared_ptr. Lather, rinse, repeat for other ABIs. Yes, this may be cumbersome, but no more than what you are already doing. Tony