
Hello, I want to make a functor which uses automatically an reference type if the provided value isn't a pointer. Now I have thougth to use the call_traits library. template<typename Value> struct Setter { typedef void result_type; void operator()(const std::wstring& newVal, Value* pVal) { *pVal = boost::lexical_cast<typename Value>(newVal); } void operator()(const std::wstring& newVal, typename boost::call_traits<Value>::reference refVal) { refVal = boost::lexical_cast<typename Value>(newVal); } }; To call the function I have the following statement: SetValue setter = boost::bind(Setter<short>(),_1,x); Now the only thing that I don't like very much is that the user has to provide the template argument for setter. Is there some possibility to solve it that the template argument is automatically deduced? Important is that I have to possible calls one when the value is provided as value -> I need to have a reference parameter and the other is when a pointer is provided. It would be great if someone can give me a hint. Best regards Hansjörg