1 //===-- type_traits.h -------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef SCUDO_TYPE_TRAITS_H_ 10 #define SCUDO_TYPE_TRAITS_H_ 11 12 namespace scudo { 13 14 template <typename T> struct removeConst { 15 using type = T; 16 }; 17 template <typename T> struct removeConst<const T> { 18 using type = T; 19 }; 20 21 // This is only used for SFINAE when detecting if a type is defined. 22 template <typename T> struct voidAdaptor { 23 using type = void; 24 }; 25 26 template <typename L, typename R> struct assertSameType { 27 template <typename, typename> struct isSame { 28 static constexpr bool value = false; 29 }; 30 template <typename T> struct isSame<T, T> { 31 static constexpr bool value = true; 32 }; 33 static_assert(isSame<L, R>::value, "Type mismatches"); 34 using type = R; 35 }; 36 37 template <typename T> struct isPointer { 38 static constexpr bool value = false; 39 }; 40 41 template <typename T> struct isPointer<T *> { 42 static constexpr bool value = true; 43 }; 44 45 } // namespace scudo 46 47 #endif // SCUDO_TYPE_TRAITS_H_ 48