RE: [Boost-users] About properties
...
I guess the functionality he wants is like the property keyword in VC++. Unfortunately this is a Microsoft only extension.
This is acutally stolen by Microsoft from Borland Delphi's Object Pascal. I really liked the feature and wished C++ had a solution. I haven't spent any time thinking about adding it, or how to.
Any ideas? Suggestions?
Thanks
-delfin
-matt _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
In article <29D3D0247B11324DABB7D9C7506AB4D0070810DF@MLBMX8.cs.myharris.net>,
"Townsend, Matthew"
I guess the functionality he wants is like the property keyword in VC++. Unfortunately this is a Microsoft only extension.
This is acutally stolen by Microsoft from Borland Delphi's Object Pascal.
I really liked the feature and wished C++ had a solution. I haven't spent any time thinking about adding it, or how to.
AFAIK there is a proposal to add this to C++ but I don't think it's been accepted yet. meeroh
I guess the functionality he wants is like the property keyword in VC++. Unfortunately this is a Microsoft only extension.
This is acutally stolen by Microsoft from Borland Delphi's Object Pascal.
I really liked the feature and wished C++ had a solution. I haven't spent any time thinking about adding it, or how to.
Any ideas? Suggestions?
Thanks
Boost.Test library contain header class property that implement AFAICT the solution to your problem: Example usage like this: Example1: class A{ public: A( std::string name ) : p_name( name ) {} readonly_propertystd::string p_name; }; ... A a; std::cout << a.p_name; or std::string s( a.p_name ); a.p_name = "abc"; <-- this will produce error a.p_name.value = "abc"; <-- this will produce error Example2: class A{ public: readwrite_property<int> p_id; }; ... A a; std::cout << a.p_id; a.p_id.value = 1; Example3: class A { public: BOOST_READONLY_PROPERTY( float, (B)(C) ) p_highwatermark; }; This is an example of readonly property that only accessible for modification to the methods of classes B and C HTH, Header is here: boost/test/detail/class_properties.hpp (Old version is here: http://www.boost.org/boost/test/detail/class_properties.hpp, but I recommend to use new from cvs or one that will come with next release) Gennadiy
Gennadiy Rozental wrote:
Boost.Test library contain header class property that implement AFAICT the solution to your problem:
[snip] I had completely forgotten about that part of the library. I think that's the best bet. However, I've come across an alternative before: http://freshmeat.net/projects/libpropc/ Unfortunately the licensing is somewhat restrictive (LGPL, though there's also a commercial license). HTH, Matt
participants (4)
-
Gennadiy Rozental
-
Matt S Trentini
-
Miro Jurisic
-
Townsend, Matthew