I'm trying to pass an enum which is basically a byte to a overload resolution, but it doesn't work.
Here is the enum:
enum class WriteOp : uint8_t {
kAdd = 0,
kDelete
};
Here are the overloads:
void copy_out(uint8_t& v) { getn((char*) &v, 1); }
void copy_out(uint16_t& v) { getn((char*) &v, 2); }
void copy_out(uint32_t& v) { getn((char*) &v, 4); }
void copy_out(uint64_t& v) { getn((char*) &v, 8); }
And here is a typical error messages I'm getting:
main.cpp:164:8: note: candidate function not viable: no known conversion from 'WriteOp' to 'uint8_t &' (aka 'unsigned char &') for 1st argument
void copy_out(uint8_t& v) { getn((char*) &v, 1); }
Any simple and elegant way to do that?