aligator
0.9.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
3
#include "
aligator/python/fwd.hpp
"
4
#include <proxsuite-nlp/python/polymorphic.hpp>
5
6
#include <boost/mpl/vector.hpp>
7
8
namespace
aligator::python
{
9
using
proxsuite::nlp::python::PolymorphicVisitor;
10
using
proxsuite::nlp::python::register_polymorphic_to_python;
11
15
template
<
class
... Bases>
16
struct
PolymorphicMultiBaseVisitor
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
fwd.hpp
aligator::python
The Python bindings.
Definition
blk-matrix.hpp:5
aligator::python::PolymorphicMultiBaseVisitor
Definition
polymorphic-convertible.hpp:17
aligator::python::PolymorphicMultiBaseVisitor::types
boost::mpl::vector< Bases *... > types
Definition
polymorphic-convertible.hpp:19
aligator::python::PolymorphicMultiBaseVisitor::visit
void visit(bp::class_< Args... > &cl) const
Definition
polymorphic-convertible.hpp:21
bindings
python
include
aligator
python
polymorphic-convertible.hpp
Generated by
1.11.0