Skip to content

Commit

Permalink
Explicit set_attribute() overload for char type of the other platform
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Dec 6, 2023
1 parent 8b138bf commit 9935eca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/binding/python/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,14 @@ template <>
struct char_to_explicit_char<true>
{
using type = signed char;
using opposite_type = unsigned char;
};

template <>
struct char_to_explicit_char<false>
{
using type = unsigned char;
using opposite_type = signed char;
};

template <typename TargetType>
Expand Down Expand Up @@ -518,7 +520,10 @@ void init_Attributable(py::module &m)

// fundamental Python types
.def("set_attribute", &Attributable::setAttribute<bool>)
.def("set_attribute", &Attributable::setAttribute<unsigned char>)
.def(
"set_attribute",
&Attributable::setAttribute<
typename ::detail::char_to_explicit_char<>::opposite_type>)
// -> handle all native python integers as long
// .def("set_attribute", &Attributable::setAttribute< short >)
// .def("set_attribute", &Attributable::setAttribute< int >)
Expand Down

0 comments on commit 9935eca

Please sign in to comment.