Skip to content

Commit

Permalink
ARROW-14475: [C++] Don't shadow enable_if helpers
Browse files Browse the repository at this point in the history
In unity builds, this can cause odd build or runtime errors when the wrong template gets used - furthermore they manifest randomly on other PRs if they happen to change things enough that CMake groups source files differently for the unity build.

Closes #11547 from lidavidm/arrow-14475

Authored-by: David Li <[email protected]>
Signed-off-by: Yibo Cai <[email protected]>
  • Loading branch information
lidavidm authored and cyb70289 committed Oct 27, 2021
1 parent 1b7178d commit 1779e94
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 138 deletions.
32 changes: 32 additions & 0 deletions cpp/src/arrow/compute/kernels/codegen_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,38 @@ struct GetOutputType<Decimal256Type> {
using T = Decimal256;
};

// ----------------------------------------------------------------------
// enable_if helpers for C types

template <typename T>
using is_unsigned_integer_value =
std::integral_constant<bool,
std::is_integral<T>::value && std::is_unsigned<T>::value>;

template <typename T>
using is_signed_integer_value =
std::integral_constant<bool, std::is_integral<T>::value && std::is_signed<T>::value>;

template <typename T, typename R = T>
using enable_if_signed_integer_value = enable_if_t<is_signed_integer_value<T>::value, R>;

template <typename T, typename R = T>
using enable_if_unsigned_integer_value =
enable_if_t<is_unsigned_integer_value<T>::value, R>;

template <typename T, typename R = T>
using enable_if_integer_value =
enable_if_t<is_signed_integer_value<T>::value || is_unsigned_integer_value<T>::value,
R>;

template <typename T, typename R = T>
using enable_if_floating_value = enable_if_t<std::is_floating_point<T>::value, R>;

template <typename T, typename R = T>
using enable_if_decimal_value =
enable_if_t<std::is_same<Decimal128, T>::value || std::is_same<Decimal256, T>::value,
R>;

// ----------------------------------------------------------------------
// Iteration / value access utilities

Expand Down
Loading

0 comments on commit 1779e94

Please sign in to comment.