Boost Cookbook

Latest recipes

Atom feed of new recipes and blog entries (only recipes)

Value outside of allowable range

Factory could not be found for name
Value: 2
Minimum: 1
Maximum: 1
Whilst searching for factory with name class Cookbook::Version
Factory type is: class Cookbook::Version

From the forums

Latest three forum posts (reverse order)

OpenBoost 1.38 released dky 14th February, 2009 06:31 (UTC)
Boost 1.38 has been released recently. There are some new libraries thrown in along with additions to accumulators (among many others). Another important milestone in this release is experimental support to build Boost using CMake (http://www.cmake.org). I personally feel this is a great step forward helping a more streamlined build system. I can now think of using distcc to build Boost at work.
How to get working with covariant shared_ptr trick? dataangel 4th March, 2008 09:18 (UTC)

Kirit said

dataangel said

The problem I'm having is that with new_ptr the wrapper function can't make a shared_ptr from the virtual function's raw pointer anymore: the compiler complains ~MyClass() is private (as new_ptr's usage suggests it should be).

The private constructors and destructor is there to ensure that objects of that type cannot be constructed on the stack. If that isn't relevant then you wouldn't do that.

As for the compiler's complaint, is there a reason you don't just extend friendship to the wrapper function?

Sorry I wasn't clear — the complaint from the compiler isn't that the wrapper function doesn't have permission. The wrapper function is already part of the class so AFAICT friendship wouldn't make a difference. The problem is that boost::shared_ptr's internals don't have access to the destructor. Looking at the new_ptr code, it looks like your trick is to pass the shared_ptr constructor an alternative deallocator, so it doesn't have this problem. But when the wrapper function wants to make a shared_ptr out of the raw pointer it already has, it can't use new_ptr (because the object has already been allocated), nor does it have access to new_ptr's deallocator. I guess I could reproduce the trick with my class having it's own new_ptr-like deallocate function, but that's getting awfully hacky…

How to get working with covariant shared_ptr trick? Kirit 2nd March, 2008 06:40 (UTC)

dataangel said

The problem I'm having is that with new_ptr the wrapper function can't make a shared_ptr from the virtual function's raw pointer anymore: the compiler complains ~MyClass() is private (as new_ptr's usage suggests it should be).

The private constructors and destructor is there to ensure that objects of that type cannot be constructed on the stack. If that isn't relevant then you wouldn't do that.

As for the compiler's complaint, is there a reason you don't just extend friendship to the wrapper function?

Welcome to Boost cookbook (alpha). From an idea by dhruva and spec from Steve Toledo-Brown. Alpha version written by Kirit over a weekend. And yes, the site is nearly all C++ and uses Boost.

Latest blog post

Boost 1.37 released

Boost 1.37 is out. This marks another release on Boost's new schedule and well done to everybody for managing to get it done.

There is one new library, Proto, for making embedded domain specific languages (EDSLs) in C++ together with updates to several other libraries (Asio, Circular Buffer, Dynamic Bitset, Hash, Interprocess, Intrusive, Math, Type Traits, and Unordered)

Kirit, 4th November, 2008 13:17 (UTC)

Discussion for this page

Discussion for this page


This is not an official Boost site. For more information on Boost please see Boost.org.