15 #ifndef WPIUTIL_WPI_POINTERLIKETYPETRAITS_H
16 #define WPIUTIL_WPI_POINTERLIKETYPETRAITS_H
20 #include <type_traits>
32 : std::integral_constant<size_t, ConstantLog2<N / 2>::value + 1> {};
33 template <>
struct ConstantLog2<1> : std::integral_constant<size_t, 0> {};
37 static const bool value =
false;
43 static const bool value =
true;
51 static const bool value =
true;
57 static inline void *getAsVoidPointer(T *P) {
return P; }
58 static inline T *getFromVoidPointer(
void *P) {
return static_cast<T *>(P); }
64 static inline void *getAsVoidPointer(
void *P) {
return P; }
65 static inline void *getFromVoidPointer(
void *P) {
return P; }
74 enum { NumLowBitsAvailable = 2 };
81 static inline const void *getAsVoidPointer(
const T P) {
82 return NonConst::getAsVoidPointer(P);
84 static inline const T getFromVoidPointer(
const void *P) {
85 return NonConst::getFromVoidPointer(const_cast<void *>(P));
87 enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
94 static inline const void *getAsVoidPointer(
const T *P) {
95 return NonConst::getAsVoidPointer(const_cast<T *>(P));
97 static inline const T *getFromVoidPointer(
const void *P) {
98 return NonConst::getFromVoidPointer(const_cast<void *>(P));
100 enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
105 static inline void *getAsVoidPointer(uintptr_t P) {
106 return reinterpret_cast<void *>(P);
108 static inline uintptr_t getFromVoidPointer(
void *P) {
109 return reinterpret_cast<uintptr_t>(P);
112 enum { NumLowBitsAvailable = 0 };
123 template <
int Alignment,
typename FunctionPo
interT>
126 static inline void *getAsVoidPointer(FunctionPointerT P) {
127 assert((reinterpret_cast<uintptr_t>(P) &
128 ~((uintptr_t)-1 << NumLowBitsAvailable)) == 0 &&
129 "Alignment not satisfied for an actual function pointer!");
130 return reinterpret_cast<void *>(P);
132 static inline FunctionPointerT getFromVoidPointer(
void *P) {
133 return reinterpret_cast<FunctionPointerT>(P);
144 template <
typename ReturnT,
typename... ParamTs>