25 #ifndef XAPIAN_INCLUDED_ALIGNMENT_CAST_H 26 #define XAPIAN_INCLUDED_ALIGNMENT_CAST_H 28 #include <type_traits> 37 template<
typename T,
typename U>
38 typename std::enable_if<std::is_const<typename std::remove_pointer<U>::type>::value, T>::type
41 return static_cast<T
>(
static_cast<const void*
>(ptr));
51 template<
typename T,
typename U>
52 typename std::enable_if<!std::is_const<typename std::remove_pointer<U>::type>::value, T>::type
55 return static_cast<T
>(
static_cast<void*
>(ptr));
std::enable_if< std::is_const< typename std::remove_pointer< U >::type >::value, T >::type alignment_cast(U ptr)
Cast a pointer we know is suitably aligned.