aboutsummaryrefslogtreecommitdiff
path: root/tests/Utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Utils.h')
-rw-r--r--tests/Utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/Utils.h b/tests/Utils.h
index 4745b8bbd7..465cba88ab 100644
--- a/tests/Utils.h
+++ b/tests/Utils.h
@@ -106,6 +106,10 @@ using promote_t = typename promote<T>::type;
template <typename T>
using make_signed_conditional_t = typename std::conditional<std::is_integral<T>::value, std::make_signed<T>, std::common_type<T>>::type;
+
+template <typename T>
+using make_unsigned_conditional_t = typename std::conditional<std::is_integral<T>::value, std::make_unsigned<T>, std::common_type<T>>::type;
+
// clang-format on
// *INDENT-ON*
}
@@ -298,6 +302,16 @@ struct common_promoted_signed_type
using intermediate_type = typename traits::make_signed_conditional_t<promoted_type>::type;
};
+/** Find the unsigned promoted common type.
+ */
+template <typename... T>
+struct common_promoted_unsigned_type
+{
+ using common_type = typename std::common_type<T...>::type;
+ using promoted_type = traits::promote_t<common_type>;
+ using intermediate_type = typename traits::make_unsigned_conditional_t<promoted_type>::type;
+};
+
/** Convert a linear index into n-dimensional coordinates.
*
* @param[in] shape Shape of the n-dimensional tensor.