eigenpy
3.13.0
Bindings between Numpy and Eigen using Boost.Python
Toggle main menu visibility
Loading...
Searching...
No Matches
type_info.hpp
1
4
5
#ifndef __eigenpy_type_info_hpp__
6
#define __eigenpy_type_info_hpp__
7
8
#include "eigenpy/fwd.hpp"
9
10
#include <boost/type_index.hpp>
11
#include <typeinfo>
12
#include <typeindex>
13
14
namespace
eigenpy
{
15
16
template
<
typename
T>
17
boost::typeindex::type_index type_info(
const
T& value) {
18
return
boost::typeindex::type_id_runtime(value);
19
}
20
21
template
<
typename
T>
22
void
expose_boost_type_info() {
23
boost::python::def(
24
"type_info"
,
25
+[](
const
T& value) -> boost::typeindex::type_index {
26
return
boost::typeindex::type_id_runtime(value);
27
},
28
bp::arg(
"value"
),
29
"Returns information of the type of value as a "
30
"boost::typeindex::type_index (can work without RTTI)."
);
31
boost::python::def(
32
"boost_type_info"
,
33
+[](
const
T& value) -> boost::typeindex::type_index {
34
return
boost::typeindex::type_id_runtime(value);
35
},
36
bp::arg(
"value"
),
37
"Returns information of the type of value as a "
38
"boost::typeindex::type_index (can work without RTTI)."
);
39
}
40
41
template
<
typename
T>
42
void
expose_std_type_info() {
43
boost::python::def(
44
"std_type_info"
,
45
+[](
const
T& value) -> std::type_index {
return
typeid
(value); },
46
bp::arg(
"value"
),
47
"Returns information of the type of value as a std::type_index."
);
48
}
49
53
template
<
class
C>
54
struct
TypeInfoVisitor
:
public
bp::def_visitor<TypeInfoVisitor<C>> {
55
template
<
class
PyClass>
56
void
visit(PyClass& cl)
const
{
57
cl.def(
"type_info"
, &boost_type_info, bp::arg(
"self"
),
58
"Queries information of the type of *this as a "
59
"boost::typeindex::type_index (can work without RTTI)."
);
60
cl.def(
"boost_type_info"
, &boost_type_info, bp::arg(
"self"
),
61
"Queries information of the type of *this as a "
62
"boost::typeindex::type_index (can work without RTTI)."
);
63
cl.def(
"std_type_info"
, &std_type_info, bp::arg(
"self"
),
64
"Queries information of the type of *this as a std::type_index."
);
65
}
66
67
private
:
68
static
boost::typeindex::type_index boost_type_info(
const
C& self) {
69
return
boost::typeindex::type_id_runtime(self);
70
}
71
72
static
std::type_index std_type_info(
const
C& self) {
return
typeid
(self); }
73
};
74
75
}
// namespace eigenpy
76
77
#endif
// __eigenpy_type_info_hpp__
eigenpy
Definition
alignment.hpp:14
eigenpy::TypeInfoVisitor
Add the Python method type_info to query information of a type.
Definition
type_info.hpp:54
include
eigenpy
type_info.hpp
Generated by
1.17.0