Subject: Re: [boost] [property] interest in C# like properties for C++?
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2009-10-21 16:50:58
> A.X() = B.X() = 5 isn't horrible, but A.X = B.X = 5 is what one expects when
one thinks of "properties."
Sorry, if I jump in in the middle of the discussion.
Boost.Test uses properties with syntax like this:
int i = a.p_X;
a.p_X.value = 1;
This syntax IMO has couple advantages:
1. From encapsulation standpoint this is as good as having explicit setter and
2. I do not like to allow a.p_X = 1. ".value" syntax allows me to grep easily
for all the encounters of property modification. This is especially useful in
situations where there are myriads of read-only access and only couple mutating
3. Single line definition:
Instead of 3 lines required by data member, getter and setter.
4. I also have readonly_property, which can restrict mutating access to the
property value for all classes (in which case property initialized in a
constructor once and never changes). Or I can have readonly property with fixed
list of classes allowed mutating access.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk