[C++-sig] wrapping complex attributes

David Abrahams dave at boost-consulting.com
Wed Nov 13 00:13:11 CET 2002

"Mike Rovner" <mike at bindkey.com> writes:

> Here is another dark corner:
> I have a complex C++ object:
> class Heavy {
>   void SetX(const char *name, const T1& val);
>   T1 GetX(const char *name);
>   void DelX(const char *name);
>   Iter<T1> EnumX();
>   void SetY(const char *name, const T2& val);
>   T2 GetY(const char *name);
>   void DelY(const char *name);
>   Iter<T2> EnumY();
>   void SetZ(const char *name, const T3& val);
>   T3 GetZ(const char *name);
>   void DelZ(const char *name);
>   Iter<T3> EnumZ();
> }
> It seems natural to expose class Heavy with 3 attributes: x,y and z which
> will behave like dictionaries.
> How to do that?

Use the add_property member of class_<>:


                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

More information about the Cplusplus-sig mailing list