#include #include #include class sum { int val_sum; public: sum(int a, int b) : val_sum(a + b) { } operator int() const { return this->val_sum; } }; template < class Source > struct factory_fwd : boost::forward_adapter > { factory_fwd(void) : boost::forward_adapter >(boost::factory()) {} }; int main() { #define one 1 #define two 2 { sum* instance( factory_fwd< sum* >()(one,two) ); BOOST_TEST(*instance == 3); } return boost::report_errors(); }