dolphin-emu/dolphin — pull request #605 by neobrain (2014-07-12 12:43:23+00:00)
Title: MMIO: Cleanup Mapping class by using templates instead of macros.

Macros aren't a particular modern way of using C++ to begin with, but in this case I think using templates instead of macros indeed makes the code a lot more readable. Additionally, I was able to clean up the interface a lot because the C++ overloading restrictions don't affect templated code.

For what it's worth, I'm not sure if

template
struct HandlerArray
{
using Read = std::array, NUM_MMIOS / sizeof(Unit)>;
using Write = std::array, NUM_MMIOS / sizeof(Unit)>;
};

HandlerArray::Read m_read_handlers8;
HandlerArray::Read m_read_handlers16;
HandlerArray::Read m_read_handlers32;

HandlerArray::Write m_write_handlers8;
HandlerArray::Write m_write_handlers16;
HandlerArray::Write m_write_handlers32;
is any cleaner than

std::array, NUM_MMIOS / sizeof(Unit)> m_read_handlers8;
std::array, NUM_MMIOS / sizeof(Unit)> m_read_handlers16;
std::array, NUM_MMIOS / sizeof(Unit)> m_read_handlers32;

std::array, NUM_MMIOS / sizeof(Unit)> m_write_handlers8;
std::array, NUM_MMIOS / sizeof(Unit)> m_write_handlers16;
std::array, NUM_MMIOS / sizeof(Unit)> m_write_handlers32;
Opinions on that? (having written this in comparison, I got to say myself that the second version is probably better)