diff options
Diffstat (limited to 'src/osd/osdcomm.h')
-rw-r--r-- | src/osd/osdcomm.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index a376ee6b9bd..ff8ca667713 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -17,6 +17,8 @@ #include <stdio.h> #include <string.h> #include <cstdint> +#include <type_traits> + /*************************************************************************** COMPILER-SPECIFIC NASTINESS @@ -131,6 +133,15 @@ using FPTR = uintptr_t; // Highly useful template for compile-time knowledge of an array size template <typename T, size_t N> constexpr inline size_t ARRAY_LENGTH(T (&)[N]) { return N;} +// For declaring an array of the same dimensions as another array (including multi-dimensional arrays) +template <typename T, typename U> struct equivalent_array_or_type { typedef T type; }; +template <typename T, typename U, std::size_t N> struct equivalent_array_or_type<T, U[N]> { typedef typename equivalent_array_or_type<T, U>::type type[N]; }; +template <typename T, typename U> using equivalent_array_or_type_t = typename equivalent_array_or_type<T, U>::type; +template <typename T, typename U> struct equivalent_array { }; +template <typename T, typename U, std::size_t N> struct equivalent_array<T, U[N]> { typedef equivalent_array_or_type_t<T, U> type[N]; }; +template <typename T, typename U> using equivalent_array_t = typename equivalent_array<T, U>::type; +#define EQUIVALENT_ARRAY(a, T) equivalent_array_t<T, std::remove_reference_t<decltype(a)> > + /* Macros for normalizing data into big or little endian formats */ #define FLIPENDIAN_INT16(x) (((((UINT16) (x)) >> 8) | ((x) << 8)) & 0xffff) |