diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h index cb7f524447a5e..80713e17a56b9 100644 --- a/llvm/include/llvm/Support/type_traits.h +++ b/llvm/include/llvm/Support/type_traits.h @@ -39,35 +39,21 @@ template class is_integral_or_enum { }; /// If T is a pointer, just return it. If it is not, return T&. -template -struct add_lvalue_reference_if_not_pointer { - using type = T &; -}; - -template -struct add_lvalue_reference_if_not_pointer< - T, std::enable_if_t>> { - using type = T; +template struct add_lvalue_reference_if_not_pointer { + using type = std::conditional_t, T, T &>; }; /// If T is a pointer to X, return a pointer to const X. If it is not, /// return const T. -template struct add_const_past_pointer { - using type = const T; +template struct add_const_past_pointer { + using type = std::conditional_t, + const std::remove_pointer_t *, const T>; }; -template -struct add_const_past_pointer>> { - using type = const std::remove_pointer_t *; -}; - -template -struct const_pointer_or_const_ref { - using type = const T &; -}; -template -struct const_pointer_or_const_ref>> { - using type = typename add_const_past_pointer::type; +template struct const_pointer_or_const_ref { + using type = + std::conditional_t, + typename add_const_past_pointer::type, const T &>; }; namespace detail {