6 #define BOOST_FUSION_INVOKE_MAX_ARITY 10 16 #include "pinocchio/tools/timer.hpp" 19 #include <boost/test/unit_test.hpp> 20 #include <boost/utility/binary.hpp> 25 TestObj() : i(0) { std::cout <<
"Test()" << std::endl; }
26 TestObj(
int i) : i(i) { std::cout <<
"Test(int)" << std::endl; }
35 const D&
derived()
const {
return static_cast<const D&
> (*this); }
37 void f() {
static_cast<D*
>(
this)->
f(); }
38 int g() {
return static_cast<D*
>(
this)->
g(); }
39 int h(
const double & x) {
return static_cast<D*
>(
this)->
h(x); }
40 int hh(
const double & x,
const int & y,
const Eigen::MatrixXd & z,
const TestObj &
a) {
return static_cast<D*
>(
this)->
hh(x,y,z,a); }
45 void f() { std::cout <<
"f()" << std::endl; }
46 int g() { std::cout <<
"g()" << std::endl;
return 1; }
47 int h(
const double & x) { std::cout <<
"h(" << x <<
")" << std::endl;
return 2; }
48 int hh(
const double & x,
const int & y,
const Eigen::MatrixXd & z,
const TestObj & )
49 { std::cout <<
"hh(" << x <<
"," << y <<
"," << z <<
",a)" << std::endl;
return 3; }
54 void f() { std::cout <<
"f()" << std::endl; }
55 int g() { std::cout <<
"g()" << std::endl;
return 1; }
56 int h(
const double & x) { std::cout <<
"h(" << x <<
")" << std::endl;
return 2; }
57 int hh(
const double & x,
const int & y,
const Eigen::MatrixXd & z,
const TestObj & )
58 { std::cout <<
"hh(" << x <<
"," << y <<
"," << z <<
",a)" << std::endl;
return 3; }
76 #include <boost/variant.hpp> 79 #include <boost/fusion/include/sequence.hpp> 80 #include <boost/fusion/include/make_vector.hpp> 81 #include <boost/fusion/include/next.hpp> 82 #include <boost/fusion/include/invoke.hpp> 83 #include <boost/fusion/view/joint_view.hpp> 84 #include <boost/fusion/include/joint_view.hpp> 85 #include <boost/fusion/algorithm.hpp> 86 #include <boost/fusion/container.hpp> 91 struct Launcher :
public boost::static_visitor<int>
94 typedef bf::vector<
const double &,
const int &,
const Eigen::MatrixXd &,
95 const Eigen::MatrixXd &,
const Eigen::MatrixXd &,
const TestObj &>
Args;
103 return bf::invoke(&Launcher::algo<D>,bf::push_front(args,boost::ref(dref)));
108 return boost::apply_visitor(
Launcher(args),crtp );
112 static int algo(
CRTPBase<D> & crtp,
const double & x,
const int & y,
const Eigen::MatrixXd & z,
113 const Eigen::MatrixXd & ,
const Eigen::MatrixXd & ,
const TestObj &
a)
115 return crtp.
hh(x,y,z,a);
121 template<
typename T,
typename V>
123 append(
T const&
t,
V const&
v) {
return push_front(v,t); }
125 template<
typename T1,
typename T2,
typename V>
127 append2(T1
const& t1,T2
const& t2,V
const& v) {
return push_front(push_front(v,t2),t1); }
152 Eigen::MatrixXd::Zero(3,3),
TestObj(1)) );
155 bf::vector<int&> arg = bf::make_vector(boost::ref(j));
157 bf::vector<double &,int &> arg1 =
bf::append(boost::ref(k),arg);
158 bf::vector<int &,double &,int &> arg11 =
bf::append(boost::ref(
i),arg1);
160 bf::vector<int &,double &,int &> arg2 =
bf::append2(boost::ref(
i),boost::ref(k),arg);
164 BOOST_AUTO_TEST_SUITE_END ()
boost::variant< CRTPDerived, CRTPDerived2 > CRTPVariant
result_of::push_front< V const, T >::type append(T const &t, V const &v)
Append the element T at the front of boost fusion vector V.
int hh(const double &x, const int &y, const Eigen::MatrixXd &z, const TestObj &)
virtual CollisionGeometry * clone() const=0
static int algo(CRTPBase< D > &crtp, const double &x, const int &y, const Eigen::MatrixXd &z, const Eigen::MatrixXd &, const Eigen::MatrixXd &, const TestObj &a)
TestObj(const TestObj &clone)
BOOST_AUTO_TEST_CASE(test_fusion)
static int run(CRTPVariant &crtp, Args args)
bf::vector< const double &, const int &, const Eigen::MatrixXd &, const Eigen::MatrixXd &, const Eigen::MatrixXd &, const TestObj & > Args
const D & derived() const
#define BOOST_TEST_MODULE
int hh(const double &x, const int &y, const Eigen::MatrixXd &z, const TestObj &a)
result_of::push_front< typename result_of::push_front< V const, T2 >::type const, T1 >::type append2(T1 const &t1, T2 const &t2, V const &v)
int hh(const double &x, const int &y, const Eigen::MatrixXd &z, const TestObj &)