Skip to content

Commit

Permalink
fix: C++17 makes noexcept part of the type system
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Jan 22, 2022
1 parent 1b1d7d7 commit 1915fb8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions include/bh_python/register_axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@
#include <vector>

template <class T>
auto vectorize_index(T&& input) {
return py::vectorize(std::forward<T>(input));
auto vectorize_index(T input) {
return py::vectorize(input);
}

#ifdef __cpp_noexcept_function_type
# define BHP_NOEXCEPT_17 noexcept
#else
#define BHP_NOEXCEPT_17
#endif

// we overload vectorize index for category axis
template <class T, class Options>
auto vectorize_index(int (bh::axis::category<T, metadata_t, Options>::*pindex)(const T&)
const) {
const BHP_NOEXCEPT_17) {
return [pindex](const bh::axis::category<T, metadata_t, Options>& self,
py::object arg) -> py::object {
auto index = std::mem_fn(pindex);
Expand Down Expand Up @@ -66,13 +72,13 @@ auto vectorize_index(int (bh::axis::category<T, metadata_t, Options>::*pindex)(c
}

template <class T>
auto vectorize_value(T&& input) {
return py::vectorize(std::forward<T>(input));
auto vectorize_value(T input) {
return py::vectorize(input);
}
// we overload vectorize value for category axis
template <class R, class U, class Options>
auto vectorize_value(R (bh::axis::category<U, metadata_t, Options>::*pvalue)(int)
const) {
const BHP_NOEXCEPT_17) {
return [pvalue](const bh::axis::category<U, metadata_t, Options>& self,
py::object arg) -> py::object {
auto value = std::mem_fn(pvalue);
Expand Down Expand Up @@ -102,6 +108,8 @@ auto vectorize_value(R (bh::axis::category<U, metadata_t, Options>::*pvalue)(int
};
}

#undef BHP_NOEXCEPT_17

/// Add helpers common to all axis types
template <class A, class... Args>
py::class_<A> register_axis(py::module& m, Args&&... args) {
Expand Down

0 comments on commit 1915fb8

Please sign in to comment.