A macro like this could be of use, though it's arguably ugly:
#include <boost/preprocessor.hpp>
#define AUTO_CONSTRUCTOR_DETAIL_PARAM(r, data, member) \
BOOST_TYPEOF(member) member
#define AUTO_CONSTRUCTOR_DETAIL_INIT(r, data, member) \
member(member)
#define AUTO_CONSTRUCTOR_DETAIL(className, mems) \
className(BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM( \
AUTO_CONSTRUCTOR_DETAIL_PARAM, BOOST_PP_EMPTY, members))) : \
BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM( \
AUTO_CONSTRUCTOR_DETAIL_INIT, BOOST_PP_EMPTY, member)) \
{}
#define AUTO_CONSTRUCTOR(className, members) \
AUTO_CONSTRUCTOR_DETAIL(className, members)
Use as:
struct MyFunctor {
public:
AUTO_CONSTRUCTOR(MyFunctor, (m_controller)(m_action)(m_allowRejection))
bool operator()() { return true; }
private:
Controller *m_controller;
String m_action;
bool m_allowRejection;
/* ... */
};
Untested, of course.