On Sunday 07 July 2013 17:04:14 Metodi Todorov wrote:
Is there any interest of "C# property" like library?
struct vec2 { float get_x() const{...} float set_x() const{...} ... property_rw
x; vec2() : y(this) {} }; vec2 v; v.x = 15.0f; cout << v.x << endl;
Example: http://sourceforge.net/projects/cproperty/?source=dlp
I must say I'm not sure I see the point of x. You already had to define set_x/get_x, so you already concealed the nature of the property x (which is why properties exist, right?). One additional downside I see is that you have to store this inside the property, which adds to the vec2 object size and also affects its copyability/movability (i.e. you can't just have a default implementation of these functions). And you're bound to the particular signatures of the set/get functions.