I have been strugling the past weeks designing a system to add ".net style" properties to my library. After some experiments like wrapping the class members inside member<type> m_member stuff I realized that I was wrong about what exactly a property is. So I rewrote everything again with the following idea in mind:

A property is nothing more that a pack of some accessor functions and maybe some data.

My objective was to support properties while keeping the class size the same and without any speed impact or weird requeriment in the get/set functions. The code is working right now but I think it can be more compact for the user, but unfortunately my c++ skills are insuficient to polish some things. Here is an example:

This block shows how the system actually works:

    {
    rectangle_i r(1,2,3,4);
    size_i sz = get_property<size_i>(r, L"size");
    get_property(sz, r, L"size");
    set_property(r, L"size", size_i(10,20));
    bool IsEmpty; get_property(IsEmpty, r, L"IsEmpty");
    rectangle_i r2(10,1,1,1); get_property(r2, r, L"empty");
    }

And this section of a common rectangle class (ripped from .net api) shows how to register this "properties":

template <class T_> class rectangle
{
// ...

        const point<T_>&    get_location() const {return m_location;}
        void                        set_location(const point<T_>& value) {m_location = value;}

        static void        initialize_property_pool(property_pool& out)
            {
            out.add<rectangle<T_>, point<T_>>(L"location", &rectangle<T_>::get_location, &rectangle<T_>::set_location);
            out.add<rectangle<T_>, size<T_>>(L"size", &rectangle<T_>::get_size, &rectangle<T_>::set_size);
            out.add<rectangle<T_>, T_>(L"height", &rectangle<T_>::get_height, &rectangle<T_>::set_height);
            out.add<rectangle<T_>, T_>(L"width", &rectangle<T_>::get_width, &rectangle<T_>::set_width);
            out.add<rectangle<T_>, T_>(L"bottom", &rectangle<T_>::get_bottom, &rectangle<T_>::set_bottom);
            out.add<rectangle<T_>, T_>(L"left", &rectangle<T_>::get_left, &rectangle<T_>::set_left);
            out.add<rectangle<T_>, T_>(L"right", &rectangle<T_>::get_right, &rectangle<T_>::set_right);
            out.add<rectangle<T_>, T_>(L"top", &rectangle<T_>::get_top, &rectangle<T_>::set_top);
            out.add_read_only<rectangle<T_>, bool>(L"IsEmpty", &rectangle<T_>::get_is_empty);
            out.add_static_read_only<rectangle<T_>, rectangle<T_>>(L"empty", &rectangle<T_>::get_empty);
            }
// ...
};

I want to know if there is a way of deducing the template parameters to reduce this verborreic  initialize_property_pool function and to simplify things to the user and to replace "add_read_only" and "add_static_read_only" with just another pair of plain "add" functions.
Any observation will be apreciated,

thanks,

Isaac Lascasas.