diff --git a/simgear/structure/CMakeLists.txt b/simgear/structure/CMakeLists.txt index 9d25d3d7..7c7df4f3 100644 --- a/simgear/structure/CMakeLists.txt +++ b/simgear/structure/CMakeLists.txt @@ -28,10 +28,6 @@ set(HEADERS StateMachine.hxx ) -set(DETAIL_HEADERS - detail/function_list_template.hxx -) - set(SOURCES SGAtomic.cxx SGBinding.cxx @@ -48,7 +44,6 @@ set(SOURCES ) simgear_component(structure structure "${SOURCES}" "${HEADERS}") -simgear_component(structure/detail structure/detail "" "${DETAIL_HEADERS}") if(ENABLE_TESTS) diff --git a/simgear/structure/detail/function_list_template.hxx b/simgear/structure/detail/function_list_template.hxx deleted file mode 100644 index 92a10a27..00000000 --- a/simgear/structure/detail/function_list_template.hxx +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef SG_FUNCTION_LIST_HXX_ -# error function_list - do not include this file! -#endif - -#ifndef SG_DONT_DO_ANYTHING -#define n BOOST_PP_ITERATION() -#define SG_FUNC_TYPE boost::function -#define SG_LIST_TYPE std::vector - -template -class function_list: - public SG_LIST_TYPE -{ - public: - typedef SG_FUNC_TYPE function_type; - typedef typename SG_LIST_TYPE::iterator iterator; - typedef typename SG_LIST_TYPE::const_iterator const_iterator; - - Ret operator()(BOOST_PP_ENUM_BINARY_PARAMS(n, A, a)) const - { - if( this->empty() ) - return Ret(); - - const_iterator list_end = --this->end(); - for(const_iterator f = this->begin(); f != list_end; ++f) - if( *f ) - (*f)(BOOST_PP_ENUM_PARAMS(n, a)); - - return (*list_end) ? (*list_end)(BOOST_PP_ENUM_PARAMS(n, a)) : Ret(); - } -}; - -#undef n -#undef SG_FUNC_TYPE -#undef SG_LIST_TYPE - -#endif // SG_DONT_DO_ANYTHING diff --git a/simgear/structure/function_list.hxx b/simgear/structure/function_list.hxx index 314c16ed..5268d2ca 100644 --- a/simgear/structure/function_list.hxx +++ b/simgear/structure/function_list.hxx @@ -20,33 +20,43 @@ #define SG_FUNCTION_LIST_HXX_ #include -#include -#include -#include -#include #include namespace simgear { template class function_list; - // Build dependency for CMake, gcc, etc. -# define SG_DONT_DO_ANYTHING -# include -# undef SG_DONT_DO_ANYTHING - -# define BOOST_PP_ITERATION_LIMITS (0, 3) -# define BOOST_PP_FILENAME_1 -# include BOOST_PP_ITERATE() - /** * Handle a list of callbacks like a single boost::function. * * @tparam Sig Function signature. */ - template - class function_list >: - public function_list + template + class function_list: + public std::vector> + { + public: + Ret operator()(Args ... args) const + { + if( this->empty() ) + return Ret(); + + auto list_end = --this->end(); + for(auto f = this->begin(); f != list_end; ++f) + if( *f ) + (*f)(args...); + + return (*list_end) ? (*list_end)(args...) : Ret(); + } + }; + + /** + * Handle a list of callbacks with the same signature as the given + * boost::function type. + */ + template + class function_list>: + public function_list { };