Subject: Re: [boost] Generic type inferencer function?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2015-12-29 04:38:34
Le 25/12/2015 18:38, Bjorn Reese a écrit :
> On 12/18/2015 05:54 PM, Vicente J. Botet Escriba wrote:
>> There is a draft proposal not yet finished at
> I realize that you are attempting to generalize pre-existing make
> factories, but I still wanted to raise the following problem because
Yes, the make function is just a generalization.
> that is the main reason why I often have to avoid using make_shared.
> If I have a class T that always must be created as a shared_ptr (e.g.
> because it relies on enable_shared_from_this<T>), then I can ensure
> that the class can only be constructed via the factory by making the
> constructor of T private, and let the factory be a friend of T. This
> works fine if my factory is a static T::create(args...) function, but
> not when using make_shared<T>(args...) because in practice it uses
> internal helper functions that I cannot make friends of my class.
I believe there is a place for this kind of classes and to have an
associated factory. The question is how to recognize these kind of classes.
My library would only help you to overload make_custom so that you can write
shared_ptr<T> ptr = make<T>(args...);
make_custom will replace your T::create(args...).
Even if the library wouldn't help you a lot (as you need to customize),
would you prefer make<T>(args...) to T::create(args...)?
Maybe inheriting T from a specific class could help to identify this
kind of classes and so the customization.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk