I have some legacy code using arrays of function pointers in order to emulate memory handlers. So I'm now trying to have the same functionality using templates. Here's what I tried so far :
template <typename R, typename ...ARGS> using function = R(*)(ARGS...);
template<size_t Size> using ReadType = function<SizedUInt<Size>, const uint32_t>;
// arrays to redeclare
std::array<ReadType<8>, memory_handler_size> read_8_handler_;
std::array<ReadType<16>, memory_handler_size> read_16_handler_;
std::array<ReadType<32>, memory_handler_size> read_32_handler_;
template<size_t Size>
void initializeReadHandler(uint32_t begin,
uint32_t end,
ReadType<Size> func) {
begin >>= 16;
end >>= 16;
for (uint32_t current = begin; current <= end; ++current) {
//read_handler_[current & 0xFFFF] = func;
}
}
How can I declare the read handler arrays in order to initialize them using the templated initializeReadHandler() function ?
I don't want to use std::function as I can't afford performance overhead ...
Thanks for reading me !
Aucun commentaire:
Enregistrer un commentaire