But parent is right, you have to cast it anyways before reading from it, so might as well take the right type from the beginning.
Thus void*+size is usually the right type if ones only care for the memory representation of an object (cstring functions like memcpy, etc.)
Most likely one would have both overloads:
void Hexdump(const void *p, size_t size); // (1)
template<typename T> // (2)
inline void Hexdump(const T &obj) {
return Hexdump(&obj, sizeof(T));
}
With (2) being a wrapper to (1) that compilers will almost always inline, avoiding monomorphization costs (and (2) can also accept rvalues as argument).(1) could also take std::span<const u8>, but (void*, size) is the more common idiom, more convenient to use and to read , as it is unambiguous which overload it is.