
Am Wednesday 21 October 2009 19:26:55 schrieb Sid Sacek:
The C# language is very clear about what properties are, why they're part of the language, and how they're used.
if we were discussing the definition of a new language, I might agree with you. but this is C++. there is no point in a boost library that no one would use because using it results in public(!) class interfaces that differ from any widely used practice AND the standard library. the C# properties syntax has its benefits. having two syntaxes in parallel does not. so I wouldn't recommend using the property library in public interfaces. but that's its only intended use. from boost.org: "We aim to establish "existing practice" and provide reference implementations so that Boost libraries are suitable for eventual standardization." changing the standard library to use properties instead of accessor functions isn't an option. so why should another library, that is intended for eventual standardization, use properties? Am Wednesday 21 October 2009 15:20:23 schrieb Matt Chambers:
I don't agree that what you call C++ properties are standard or widely used. I think the get/set prefix is probably just as widely used (just
so there are 2 different standards, let's introduce a 3rd one?
not in boost or std). Even in cases where one does find both get/set properties in the style you say is standard, X() and X(value), the X(value) function almost never returns X& (with both const and non-const overloads)
many properties can't return a reference to their value
. This means that it can't be used in a chain of assignment operations like A.X(B.X(5)) which incidentally looks awful compared to A.X = B.X = 5. For properties, operator= is greater than operator() ;)
hmm...bool operator > (operator=,operator());