type_info.hpp
Go to the documentation of this file.
1 
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>
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>
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::TypeInfoVisitor::visit
void visit(PyClass &cl) const
Definition: type_info.hpp:56
eigenpy::TypeInfoVisitor::boost_type_info
static boost::typeindex::type_index boost_type_info(const C &self)
Definition: type_info.hpp:68
eigenpy::TypeInfoVisitor
Add the Python method type_info to query information of a type.
Definition: type_info.hpp:54
eigenpy::expose_boost_type_info
void expose_boost_type_info()
Definition: type_info.hpp:22
fwd.hpp
eigenpy::TypeInfoVisitor::std_type_info
static std::type_index std_type_info(const C &self)
Definition: type_info.hpp:72
eigenpy
Definition: alignment.hpp:14
eigenpy::type_info
boost::typeindex::type_index type_info(const T &value)
Definition: type_info.hpp:17
test_matrix.value
float value
Definition: test_matrix.py:161
eigenpy::expose_std_type_info
void expose_std_type_info()
Definition: type_info.hpp:42


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Nov 2 2024 02:14:45