Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update type_to_name for Layout builder cxx_14 target #2165

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions header-only/awkward/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@

namespace awkward {

// FIXME:
// The following helper variable templates are part of C++17,
// define it ourselves until we switch to it
template< class T >
constexpr bool is_integral_v = std::is_integral<T>::value;

template< class T >
constexpr bool is_signed_v = std::is_signed<T>::value;

template< class T, class U >
constexpr bool is_same_v = std::is_same<T, U>::value;

/// @brief Returns the name of a primitive type as a string.
template <typename T>
const std::string
type_to_name() {
if (std::is_integral_v<T>) {
if (std::is_signed_v<T>) {
if (is_integral_v<T>) {
if (is_signed_v<T>) {
if (sizeof(T) == 1) {
return "int8";
}
Expand Down Expand Up @@ -50,16 +62,16 @@ namespace awkward {
}
}
}
else if (std::is_same_v<T, float>) {
else if (is_same_v<T, float>) {
return "float32";
}
else if (std::is_same_v<T, double>) {
else if (is_same_v<T, double>) {
return "float64";
}
else if (std::is_same_v<T, std::complex<float>>) {
else if (is_same_v<T, std::complex<float>>) {
return "complex64";
}
else if (std::is_same_v<T, std::complex<double>>) {
else if (is_same_v<T, std::complex<double>>) {
return "complex128";
}

Expand All @@ -76,6 +88,14 @@ namespace awkward {
return "bool";
}

template <>
const std::string
type_to_name<char>() {
// This takes precedence over the unspecialized template, and therefore any
// 8-bit data that is not named char will be mapped to "int8" or "uint8".
return "char";
}


/// @brief Returns `char` string when the primitive type
/// is a character.
Expand Down