aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
polymorphic-convertible.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <proxsuite-nlp/python/polymorphic.hpp>
5
6#include <boost/mpl/vector.hpp>
7
8namespace aligator::python {
9using proxsuite::nlp::python::PolymorphicVisitor;
10using proxsuite::nlp::python::register_polymorphic_to_python;
11
15template <class... Bases>
17 : bp::def_visitor<PolymorphicMultiBaseVisitor<Bases...>> {
18 // ptr to avoid instantiating abstract class
19 using types = boost::mpl::vector<Bases *...>;
20
21 template <class... Args> void visit(bp::class_<Args...> &cl) const {
22 // use the lambda to expose conversion to polymorphic<base> for each
23 // of the types in the variadic parameter Bases
24 boost::mpl::for_each<types>([&cl](auto *arg = 0) {
25 // get the type of the passed argument
26 using base_t = std::remove_reference_t<decltype(*arg)>;
27 cl.def(PolymorphicVisitor<xyz::polymorphic<base_t>>{});
28 });
29 }
30};
31
32} // namespace aligator::python
The Python bindings.
Definition blk-matrix.hpp:5