Skip to content
Snippets Groups Projects
Commit cfa5cc0a authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Temporary workaround for pybind11 bug

parent 5924c81c
No related branches found
No related tags found
1 merge request!57Small fixes
......@@ -8,6 +8,21 @@ namespace py = pybind11;
#include <TNL/Containers/Array.h>
// pybind11 should actually take care of this inside py::format_descriptor, but apparently it does not work...
// see https://github.com/pybind/pybind11/issues/2135
template< typename T, typename = void >
struct underlying_type
{
using type = T;
};
template< typename T >
struct underlying_type< T, std::enable_if_t< std::is_enum< T >::value > >
{
using type = std::underlying_type_t< T >;
};
template< typename ArrayType >
void export_Array(py::module & m, const char* name)
{
......@@ -49,7 +64,9 @@ void export_Array(py::module & m, const char* name)
// Size of one scalar
sizeof( typename ArrayType::ValueType ),
// Python struct-style format descriptor
py::format_descriptor< typename ArrayType::ValueType >::format(),
py::format_descriptor<
typename underlying_type< typename ArrayType::ValueType >::type
>::format(),
// Number of dimensions
1,
// Buffer dimensions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment