From da5cab09bdce0c13509dadd7803c7006871b3517 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Fri, 27 Jan 2023 08:01:45 +0100 Subject: [PATCH] fix: update `type_to_name` for Layout builder `cxx_14` target (#2165) * fix: cpp tests * Update utils.h --- header-only/awkward/utils.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/header-only/awkward/utils.h b/header-only/awkward/utils.h index dbb0ae4c3f..a5a5391c32 100644 --- a/header-only/awkward/utils.h +++ b/header-only/awkward/utils.h @@ -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::value; + + template< class T > + constexpr bool is_signed_v = std::is_signed::value; + + template< class T, class U > + constexpr bool is_same_v = std::is_same::value; + /// @brief Returns the name of a primitive type as a string. template const std::string type_to_name() { - if (std::is_integral_v) { - if (std::is_signed_v) { + if (is_integral_v) { + if (is_signed_v) { if (sizeof(T) == 1) { return "int8"; } @@ -50,16 +62,16 @@ namespace awkward { } } } - else if (std::is_same_v) { + else if (is_same_v) { return "float32"; } - else if (std::is_same_v) { + else if (is_same_v) { return "float64"; } - else if (std::is_same_v>) { + else if (is_same_v>) { return "complex64"; } - else if (std::is_same_v>) { + else if (is_same_v>) { return "complex128"; } @@ -76,6 +88,14 @@ namespace awkward { return "bool"; } + template <> + const std::string + type_to_name() { + // 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.