Commit cfa5cc0a authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Temporary workaround for pybind11 bug

parent 5924c81c
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -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