
Am Wednesday 21 October 2009 05:51:39 schrieb Edward Diener:
the C++ "properties" syntax is, for example (taken from tr1::unordered_map):
float max_load_factor() const; void max_load_factor(float z);
I wouldn't even consider your proposed properties syntax "syntactic sugar". it's just a different syntax, not a better one imho.
so if there's anything missing from c++ it would be something like
#define BOOST_TRIVIAL_PROPERTY(T,name) \ T name() const{ return _name; } \ void name(T __name){ _name=__name; } \ T _name;
I don't believe a trivial property does very much. While a trivial style property such as you mention above could be part of any C++ "property" implementation, what is minimally needed beyond that is what the OP's property implementation provides, which is the ability to have some sort of backing function to set the property at the very least.
I'm not sure if we misunderstood each other or if we just disagree. so for clarification: a "backing function to set the property" would be implemented in pure c++, without any property class: void max_load_factor(float z){ ... } and replaces the formerly used BOOST_TRIVIAL_PROPERTY(float,max_load_factor); (or better, the property object David proposed) so what I was trying to say is that C++ already has an established syntax for properties, except for trivial properties that automatically implement getters/setters. and that there is no need for another, incompatible, properties syntax, which I don't even consider "better", just "different".