On 06/14/2016 09:33 AM, Tom Swirly wrote:
> Sorry for all the traffic, but I'm doing my /second /Cython project so a
> lot of ideas are coming together.
>
> It's very weird to see new() in use in modern C++ code - even if that
> C++ code is Cython.
>
> I'm wondering why the thisptr idiom has continued to flourish, when it's
> so much easier to directly use C++ types as member elements in Cython
> classes?
>
I think the problem (or part of it) is that to declare a C++ class
instance directly as a member variable in a Cython class, it must have a
default constructor. On the other hand, the constructor of the C++ class
is supposed to fully initialize the instance, which often doesn't make
sense with no arguments. Therefore, even if you have complete control
over both the Cython class and C++ class, if you follow sound
programming practices, you can still end up in situations where you
can't directly declare an instance of the C++ class inside the Cython class.
I didn't look into the Combiner example too much, but regarding
ColorVector: most container types can be empty, so that's a special case
where default constructors are pretty common and sensible.
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
cython-users...@googlegroups.com
> <mailto:
cython-users...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.