[Ns-developers] CreateObject and non-default constructors
Nicola Baldo
nbaldo at cttc.es
Mon Jun 8 05:54:21 PDT 2009
Hi Mathieu,
Mathieu Lacage wrote:
> hi,
>
> Recently, someone pointed out to me privately that we poorly support
> calling non-default constructors with CreateObject. In fact, we don't
> support it. I will skip over the lengthy discussion of how we ended up
> where we are today, and, instead, will get to what we could do to
> support this: 2 options (patches attached).
>
> 1. compatible option (a.patch)
> 2. less compatible option (b.patch)
>
> 1) compatible option: introduce CreateObjectNoAttributes:
>
> template <typename T>
> Ptr<T> CreateObjectNoAttributes (void);
>
> template <typename T, typename T1>
> Ptr<T> CreateObjectNoAttributes (T1 a1);
>
> template <typename T, typename T1, typename T2>
> Ptr<T> CreateObjectNoAttributes (T1 a1, T2 a2);
>
> ...
>
> It's not very pretty for something which appears to be regularly
> complained about by users.
>
> 2) less compatible option: modify CreateObject, introduce
> CreateObjectWithAttributes
>
> Despite not being fully compatible with existing code, I expect the
> fallout on users to be minimal because, frankly, no one calls
> CreateObject<> with construction-time attributes so, almost no one will
> notice this change.
I prefer the second alternative, because it makes the use of non-default
constructors for Object similar to that of RefCountBase.
Nicola
More information about the Ns-developers
mailing list