|
Boost : |
Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2009-10-19 21:04:23
Sid Sacek escribió:
> Sorry, but your design is flawed.
>
> This code should compile according to your design and the C# rules, but it doesn't. For it to actually be C# compliant, a property must take up no space at all, but yours does, unfortunately. Since you're embedding an object inside another object, I don't see how you can use this design to achieve that goal. No disrespect.
This is indeed true, but it will always be the case for a member object.
Since the technique already relies on undefined behaviour
(derreferencing a null pointer or calling offsetof on a non-POD type),
it may do so again and pack all properties inside a union. This will fix
the space overhead to the minimum, regardless of the number of
properties. Check Boost.Proto internals for the definition of
virtual_member, it applies such trick.
I don't think I'll choose syntactic sugar if the cost is relying on
undefined behaviour.
Agustín K-ballo Bergé.-
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk