00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00045 #ifndef PCL_FOR_EACH_TYPE_H_
00046 #define PCL_FOR_EACH_TYPE_H_
00047
00048 #include <boost/mpl/is_sequence.hpp>
00049 #include <boost/mpl/begin_end.hpp>
00050 #include <boost/mpl/next_prior.hpp>
00051 #include <boost/mpl/deref.hpp>
00052 #include <boost/mpl/assert.hpp>
00053 #include <boost/mpl/aux_/unwrap.hpp>
00054 #include <boost/type_traits/is_same.hpp>
00055
00056 namespace pcl
00057 {
00058 template< bool done = true >
00059 struct for_each_type_impl
00060 {
00061 template<typename Iterator, typename LastIterator, typename F>
00062 static void execute (F) {}
00063 };
00064
00065 template<>
00066 struct for_each_type_impl<false>
00067 {
00068 template<typename Iterator, typename LastIterator, typename F>
00069 static void execute (F f)
00070 {
00071 typedef typename boost::mpl::deref<Iterator>::type arg;
00072
00073 #ifdef _WIN32
00074 boost::mpl::aux::unwrap(f, 0).operator()<arg> ();
00075 #else
00076 boost::mpl::aux::unwrap(f, 0).template operator()<arg> ();
00077 #endif
00078
00079 typedef typename boost::mpl::next<Iterator>::type iter;
00080 for_each_type_impl<boost::is_same<iter, LastIterator>::value>
00081 ::template execute<iter, LastIterator, F> (f);
00082 }
00083 };
00084
00085 template<typename Sequence, typename F>
00086 void for_each_type (F f)
00087 {
00088 BOOST_MPL_ASSERT (( boost::mpl::is_sequence<Sequence> ));
00089 typedef typename boost::mpl::begin<Sequence>::type first;
00090 typedef typename boost::mpl::end<Sequence>::type last;
00091 for_each_type_impl< boost::is_same<first, last>::value >::template execute<first, last, F> (f);
00092 }
00093 }
00094
00095 #endif //#ifndef PCL_FOR_EACH_TYPE_H_