-
Content count
8426 -
Joined
-
Last visited
Single Status Update
-
Here's a method I worked out for duplicating the semantics of Borland Delphi/C++Builder-style properties under C++11, via the use of lambda functions which capture "this" by-value:
To set one up involves code like this:code:
Array
This allows expressions such as "bar.SomeProperty = 1;" or "int x = bar.SomeProperty;".code:
Array
The usual objection to similar implementations without this-capturing lambdas, which act like anonymous private methods of the containing class, is that the class itself isn't notified of the access to the property object. This design above completely resolves that problem with a minimum requirement for boilerplate.
BTW, I designed this at work as part of a system that exposes the Borland-specific IBExpress API, for interacting with InterBase compatible libraries such as the open-source Firebird, to other compilers such as Visual C++, freeing it from dependence on the nearly unusable C++Builder IDE.