// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE #ifndef AWKWARD_CPP_HEADERS_UTILS_H_ #define AWKWARD_CPP_HEADERS_UTILS_H_ #include #include #include #include #include #include #include namespace awkward { /// @brief Returns the name of a primitive type as a string. template const std::string type_to_name() { std::cout << "Type " << typeid(T).name() << " is not recognized." << std::endl; return typeid(T).name(); } /// @brief Returns `bool` string when the primitive type /// is boolean. template <> const std::string type_to_name() { return "bool"; } /// @brief Returns `int8` string when the primitive type /// is an 8-bit signed integer. template <> const std::string type_to_name() { return "int8"; } /// @brief Returns `int16` string when the primitive type /// is a 16-bit signed integer. template <> const std::string type_to_name() { return "int16"; } /// @brief Returns `int32` string when the primitive type /// is a 32-bit signed integer. template <> const std::string type_to_name() { return "int32"; } /// @brief Returns `int64` string when the primitive type /// is a 64-bit signed integer. template <> const std::string type_to_name() { return "int64"; } /// @brief Returns `uint8` string when the primitive type /// is an 8-bit unsigned integer. template <> const std::string type_to_name() { return "uint8"; } /// @brief Returns `uint16` string when the primitive type /// is a 16-bit unsigned integer. template <> const std::string type_to_name() { return "uint16"; } /// @brief Returns `uint32` string when the primitive type /// is a 32-bit unsigned integer. template <> const std::string type_to_name() { return "uint32"; } /// @brief Returns `uint64` string when the primitive type /// is a 64-bit unsigned integer. template <> const std::string type_to_name() { return "uint64"; } /// @brief Returns `float32` string when the primitive type /// is a floating point. template <> const std::string type_to_name() { return "float32"; } /// @brief Returns `float32` string when the primitive type /// is a double floating point. template <> const std::string type_to_name() { return "float64"; } /// @brief Returns `char` string when the primitive type /// is a character. template <> const std::string type_to_name() { return "char"; } /// @brief Returns `complex64` string when the primitive type is a /// complex number with float32 real and float32 imaginary parts. template <> const std::string type_to_name>() { return "complex64"; } /// @brief Returns `complex128` string when the primitive type is a /// complex number with float64 real and float64 imaginary parts. template <> const std::string type_to_name>() { return "complex128"; } /// @brief Returns `char` string when the primitive type /// is a character. template const std::string type_to_numpy_like() { return type_to_name(); } /// @brief Returns numpy-like character code of a primitive /// type as a string. template <> const std::string type_to_numpy_like() { return "u8"; } /// @brief Returns numpy-like character code `i8`, when the /// primitive type is an 8-bit signed integer. template <> const std::string type_to_numpy_like() { return "i8"; } /// @brief Returns numpy-like character code `u32`, when the /// primitive type is a 32-bit unsigned integer. template <> const std::string type_to_numpy_like() { return "u32"; } /// @brief Returns numpy-like character code `i32`, when the /// primitive type is a 32-bit signed integer. template <> const std::string type_to_numpy_like() { return "i32"; } /// @brief Returns numpy-like character code `i64`, when the /// primitive type is a 64-bit signed integer. template <> const std::string type_to_numpy_like() { return "i64"; } template constexpr bool is_iterable{}; // FIXME: // std::void_t is part of C++17, define it ourselves until we switch to it template struct voider { using type = void; }; template using void_t = typename voider::type; template constexpr bool is_iterable().begin()), decltype(std::declval().end())>> = true; template class Ref> struct is_specialization : std::false_type {}; template