Dean Moldovan | 67b52d8 | 2016-10-16 19:12:43 +0200 | [diff] [blame^] | 1 | Casting data types |
| 2 | ################## |
| 3 | |
| 4 | .. toctree:: |
| 5 | :maxdepth: 1 |
| 6 | |
| 7 | stl |
| 8 | functional |
| 9 | chrono |
| 10 | eigen |
| 11 | custom |
| 12 | |
| 13 | The following basic data types are supported out of the box (some may require |
| 14 | an additional extension header to be included). To pass other data structures |
| 15 | as arguments and return values, refer to the section on binding :ref:`classes`. |
| 16 | |
| 17 | +---------------------------------+--------------------------+-------------------------------+ |
| 18 | | Data type | Description | Header file | |
| 19 | +=================================+==========================+===============================+ |
| 20 | | ``int8_t``, ``uint8_t`` | 8-bit integers | :file:`pybind11/pybind11.h` | |
| 21 | +---------------------------------+--------------------------+-------------------------------+ |
| 22 | | ``int16_t``, ``uint16_t`` | 16-bit integers | :file:`pybind11/pybind11.h` | |
| 23 | +---------------------------------+--------------------------+-------------------------------+ |
| 24 | | ``int32_t``, ``uint32_t`` | 32-bit integers | :file:`pybind11/pybind11.h` | |
| 25 | +---------------------------------+--------------------------+-------------------------------+ |
| 26 | | ``int64_t``, ``uint64_t`` | 64-bit integers | :file:`pybind11/pybind11.h` | |
| 27 | +---------------------------------+--------------------------+-------------------------------+ |
| 28 | | ``ssize_t``, ``size_t`` | Platform-dependent size | :file:`pybind11/pybind11.h` | |
| 29 | +---------------------------------+--------------------------+-------------------------------+ |
| 30 | | ``float``, ``double`` | Floating point types | :file:`pybind11/pybind11.h` | |
| 31 | +---------------------------------+--------------------------+-------------------------------+ |
| 32 | | ``bool`` | Two-state Boolean type | :file:`pybind11/pybind11.h` | |
| 33 | +---------------------------------+--------------------------+-------------------------------+ |
| 34 | | ``char`` | Character literal | :file:`pybind11/pybind11.h` | |
| 35 | +---------------------------------+--------------------------+-------------------------------+ |
| 36 | | ``wchar_t`` | Wide character literal | :file:`pybind11/pybind11.h` | |
| 37 | +---------------------------------+--------------------------+-------------------------------+ |
| 38 | | ``const char *`` | UTF-8 string literal | :file:`pybind11/pybind11.h` | |
| 39 | +---------------------------------+--------------------------+-------------------------------+ |
| 40 | | ``const wchar_t *`` | Wide string literal | :file:`pybind11/pybind11.h` | |
| 41 | +---------------------------------+--------------------------+-------------------------------+ |
| 42 | | ``std::string`` | STL dynamic UTF-8 string | :file:`pybind11/pybind11.h` | |
| 43 | +---------------------------------+--------------------------+-------------------------------+ |
| 44 | | ``std::wstring`` | STL dynamic wide string | :file:`pybind11/pybind11.h` | |
| 45 | +---------------------------------+--------------------------+-------------------------------+ |
| 46 | | ``std::pair<T1, T2>`` | Pair of two custom types | :file:`pybind11/pybind11.h` | |
| 47 | +---------------------------------+--------------------------+-------------------------------+ |
| 48 | | ``std::tuple<...>`` | Arbitrary tuple of types | :file:`pybind11/pybind11.h` | |
| 49 | +---------------------------------+--------------------------+-------------------------------+ |
| 50 | | ``std::reference_wrapper<...>`` | Reference type wrapper | :file:`pybind11/pybind11.h` | |
| 51 | +---------------------------------+--------------------------+-------------------------------+ |
| 52 | | ``std::complex<T>`` | Complex numbers | :file:`pybind11/complex.h` | |
| 53 | +---------------------------------+--------------------------+-------------------------------+ |
| 54 | | ``std::array<T, Size>`` | STL static array | :file:`pybind11/stl.h` | |
| 55 | +---------------------------------+--------------------------+-------------------------------+ |
| 56 | | ``std::vector<T>`` | STL dynamic array | :file:`pybind11/stl.h` | |
| 57 | +---------------------------------+--------------------------+-------------------------------+ |
| 58 | | ``std::list<T>`` | STL linked list | :file:`pybind11/stl.h` | |
| 59 | +---------------------------------+--------------------------+-------------------------------+ |
| 60 | | ``std::map<T1, T2>`` | STL ordered map | :file:`pybind11/stl.h` | |
| 61 | +---------------------------------+--------------------------+-------------------------------+ |
| 62 | | ``std::unordered_map<T1, T2>`` | STL unordered map | :file:`pybind11/stl.h` | |
| 63 | +---------------------------------+--------------------------+-------------------------------+ |
| 64 | | ``std::set<T>`` | STL ordered set | :file:`pybind11/stl.h` | |
| 65 | +---------------------------------+--------------------------+-------------------------------+ |
| 66 | | ``std::unordered_set<T>`` | STL unordered set | :file:`pybind11/stl.h` | |
| 67 | +---------------------------------+--------------------------+-------------------------------+ |
| 68 | | ``std::function<...>`` | STL polymorphic function | :file:`pybind11/functional.h` | |
| 69 | +---------------------------------+--------------------------+-------------------------------+ |
| 70 | | ``std::chrono::duration<...>`` | STL time duration | :file:`pybind11/chrono.h` | |
| 71 | +---------------------------------+--------------------------+-------------------------------+ |
| 72 | | ``std::chrono::time_point<...>``| STL date/time | :file:`pybind11/chrono.h` | |
| 73 | +---------------------------------+--------------------------+-------------------------------+ |
| 74 | | ``Eigen::Matrix<...>`` | Eigen: dense matrix | :file:`pybind11/eigen.h` | |
| 75 | +---------------------------------+--------------------------+-------------------------------+ |
| 76 | | ``Eigen::Map<...>`` | Eigen: mapped memory | :file:`pybind11/eigen.h` | |
| 77 | +---------------------------------+--------------------------+-------------------------------+ |
| 78 | | ``Eigen::SparseMatrix<...>`` | Eigen: sparse matrix | :file:`pybind11/eigen.h` | |
| 79 | +---------------------------------+--------------------------+-------------------------------+ |