Further reduction of redundant code by merging 0 param case for constructors in
This commit is contained in:
@@ -8,23 +8,8 @@
|
|||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
namespace dispatchkit
|
|
||||||
{
|
|
||||||
template<typename Class>
|
|
||||||
boost::shared_ptr<Class> constructor()
|
|
||||||
{
|
|
||||||
return boost::shared_ptr<Class>(new Class());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Class>
|
#define BOOST_PP_ITERATION_LIMITS ( 0, 10 )
|
||||||
boost::function<boost::shared_ptr<Class> ()> build_constructor()
|
|
||||||
{
|
|
||||||
typedef boost::shared_ptr<Class> (*func)();
|
|
||||||
return boost::function<boost::shared_ptr<Class> ()>(func(&(constructor<Class>)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BOOST_PP_ITERATION_LIMITS ( 1, 10 )
|
|
||||||
#define BOOST_PP_FILENAME_1 "proxy_constructors.hpp"
|
#define BOOST_PP_FILENAME_1 "proxy_constructors.hpp"
|
||||||
#include BOOST_PP_ITERATE()
|
#include BOOST_PP_ITERATE()
|
||||||
# endif
|
# endif
|
||||||
@@ -33,17 +18,17 @@ namespace dispatchkit
|
|||||||
|
|
||||||
namespace dispatchkit
|
namespace dispatchkit
|
||||||
{
|
{
|
||||||
template<typename Class, BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
template<typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
||||||
boost::shared_ptr<Class> constructor( BOOST_PP_ENUM_BINARY_PARAMS(n, Param, p) )
|
boost::shared_ptr<Class> constructor( BOOST_PP_ENUM_BINARY_PARAMS(n, Param, p) )
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<Class>(new Class( BOOST_PP_ENUM_PARAMS(n, p) ));
|
return boost::shared_ptr<Class>(new Class( BOOST_PP_ENUM_PARAMS(n, p) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Class, BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
template<typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
|
||||||
boost::function<boost::shared_ptr<Class> (BOOST_PP_ENUM_PARAMS(n, Param))> build_constructor()
|
boost::function<boost::shared_ptr<Class> (BOOST_PP_ENUM_PARAMS(n, Param))> build_constructor()
|
||||||
{
|
{
|
||||||
typedef boost::shared_ptr<Class> (*func)(BOOST_PP_ENUM_PARAMS(n, Param));
|
typedef boost::shared_ptr<Class> (*func)(BOOST_PP_ENUM_PARAMS(n, Param));
|
||||||
return boost::function<boost::shared_ptr<Class> (BOOST_PP_ENUM_PARAMS(n, Param))>(func(&(constructor<Class, BOOST_PP_ENUM_PARAMS(n, Param)>)));
|
return boost::function<boost::shared_ptr<Class> (BOOST_PP_ENUM_PARAMS(n, Param))>(func(&(constructor<Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param)>)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user