1212#include < functional>
1313#include < numeric>
1414#include < cmath>
15+
1516#include " pybind11/pybind11.h"
1617#include " pybind11/common.h"
1718#include " pybind11/complex.h"
1819
19- // Because of layout, otherwise xiterator and xtensor_forward are sufficient
2020#include " xtensor/xcontainer.hpp"
2121
2222namespace xt
@@ -91,34 +91,6 @@ namespace xt
9191
9292 namespace detail
9393 {
94- // TODO : switch on pybind11::is_fmt_numeric when it is available
95- template <typename T, typename SFINAE = void >
96- struct is_fmt_numeric
97- {
98- static constexpr bool value = false ;
99- };
100-
101- constexpr int log2 (size_t n, int k = 0 )
102- {
103- return (n <= 1 ) ? k : log2 (n >> 1 , k + 1 );
104- }
105-
106- template <typename T>
107- struct is_fmt_numeric <T, std::enable_if_t <std::is_arithmetic<T>::value>>
108- {
109- static constexpr bool value = true ;
110- static constexpr int index = std::is_same<T, bool >::value ? 0 : 1 + (
111- std::is_integral<T>::value ? log2(sizeof (T)) * 2 + std::is_unsigned<T>::value : 8 + (
112- std::is_same<T, double >::value ? 1 : std::is_same<T, long double >::value ? 2 : 0 ));
113- };
114-
115- template <class T >
116- struct is_fmt_numeric <std::complex <T>>
117- {
118- static constexpr bool value = true ;
119- static constexpr int index = is_fmt_numeric<T>::index + 3 ;
120- };
121-
12294 template <class T >
12395 struct numpy_traits
12496 {
@@ -136,7 +108,7 @@ namespace xt
136108
137109 using value_type = std::remove_const_t <T>;
138110
139- static constexpr int type_num = value_list[is_fmt_numeric<value_type>::index];
111+ static constexpr int type_num = value_list[pybind11::detail:: is_fmt_numeric<value_type>::index];
140112 };
141113 }
142114
0 commit comments