Boost logo

Boost :

Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Peder Holt (peder.holt_at_[hidden])
Date: 2009-10-21 14:01:57

2009/10/20 Matthew Chambers <matthew.chambers_at_[hidden]>

> Peder Holt wrote:
>> It now compiles without warnings, also for classes with virtual members.
>> Operator support is added for operator*.
>> Regards
>> Peder

Very nice. Do you know how reliable your reliance on UB is on the major
> platforms? If it works on MSVC 9+, GCC 4.1, and darwin, that's enough for
> me.
> I guess the only way to find out is testing the method on several compilers
and setups. My assumptions are as follows:
I assume that the address of a member in class A relative to the address of
A is the same for all instances of A.
I also assume that if you have multiple inheritance etc. this will hold for
all classes in the inheritance hierarchy.

This holds for the simple test cases that I have made, but I have no
guarantee that this is true for all cases.
Here is a link to the test battery that I have been using to test this with
GCC and VC8. If anyone has suggestions to scenarios that I haven't covered
or wants to try this out on their favorite compiler, please do so.

Do you plan to have a macro for defining simple/trivial properties with a
> single line? A more sophisticated macro could define the functions to use
> for the getter/setter (similar to how Managed C++ and C++/CLI do it AFAIK).
> Just like in C#, it encourages good design from the start of an
> implementation: the first iteration can use properties backed by simple
> member variables, while future implementations may use a more complicated
> backend without the interface ever needing to change (and without resorting
> to set/get syntax). That allows the design focus at first to be on the
> interface instead of worrying about doing a good job on both the interface
> and the implementation.
Creating the simple macros is no problem, but we first have to find out if
properties has a place in C++ and with what syntax, and if this is the way
to go to solve the problem.

> -Matt
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at