libzeug icon indicating copy to clipboard operation
libzeug copied to clipboard

Improve Property constructors

Open mjendruk opened this issue 11 years ago • 2 comments

When you create a Property with an object pointer and two method pointers, which aren't declared in the same class (e.g. in a base class), the automatical type deduction fails. So instead of Property<int>("value", object, &Class::getter, &Class::setter) you have to write Property<int, Class>("value", object, &Class::getter, &Class::setter)

mjendruk avatar Oct 15 '13 16:10 mjendruk

You could either deduct the class type using the object or using the method pointers.

Which method do you use?

scheibel avatar Oct 15 '13 19:10 scheibel

This method:

template <typename Type>
template <class Object>
ValuePropertyTemplate<Type>::ValuePropertyTemplate(const std::string & name,
    Object & object, const Type & (Object::*getter_pointer)() const,
    void (Object::*setter_pointer)(const Type &))
:   ValueProperty(name)
,   m_value(new AccessorValue<Type>(object, getter_pointer, setter_pointer))
{
}

mjendruk avatar Oct 15 '13 20:10 mjendruk