diff options
author | 2021-02-14 11:05:57 -0500 | |
---|---|---|
committer | 2021-02-14 11:05:57 -0500 | |
commit | bc0146c2038c46f789a246d5616afd7c425157f3 (patch) | |
tree | b4d39194034b4c6e56ccd4035d25636034be43ca /src/lib/util/coretmpl.h | |
parent | 91310bcdeb7ab0ff661738b212017bf836f4e8ad (diff) |
Eliminate ARRAY_LENGTH template in favor of C++17's std::size
* osdcomm.h: Move definition of EQUIVALENT_ARRAY to coretmpl.h
* sharc.cpp, gt64xxx.cpp, ym2413.cpp, gb_lcd.cpp, snes_ppu.cpp: Use STRUCT_MEMBER for save state registration
* gio/newport.cpp, megadrive/svp.cpp, nes_ctrl/bcbattle.cpp, arm7.cpp, tms9995.cpp, pckeybrd.cpp, sa1110.cpp, sa1111.cpp, jangou_blitter.cpp, vic4567.cpp: Use std::fill(_n) instead of memset
* emucore.h: Remove obsolete typedef
Diffstat (limited to 'src/lib/util/coretmpl.h')
-rw-r--r-- | src/lib/util/coretmpl.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index 438f7134fd2..18b64e7c0ff 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -535,6 +535,16 @@ std::basic_string_view<CharT, Traits> buf_to_string_view(basic_ovectorstream<Cha } +// 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) util::equivalent_array_t<T, std::remove_reference_t<decltype(a)> > + + template <typename E> using enable_enum_t = typename std::enable_if_t<std::is_enum<E>::value, typename std::underlying_type_t<E> >; |