R
red floyd
Given function pointer, say void (*func)(void*), what's the best way to
display it on an iostream?
as far as I can tell, there is no default overload for operator<<, and a
function pointer doesn't have a conversion to a void*.
The only options I can see are either a C-style cast to void* (unsafe
and ugly), or some kind of template:
template<class T, class U> ostream& operator<<(ostream&, const U&)
which does some kind of copy of the pointer value into an array of
unsigned char (memcpy, or some such), and then outputs the data
byte-by-byte. This, of course, has endian issues (and formatting issues
for oddball architectures such as 16-bit intel).
Any suggestions?
display it on an iostream?
as far as I can tell, there is no default overload for operator<<, and a
function pointer doesn't have a conversion to a void*.
The only options I can see are either a C-style cast to void* (unsafe
and ugly), or some kind of template:
template<class T, class U> ostream& operator<<(ostream&, const U&)
which does some kind of copy of the pointer value into an array of
unsigned char (memcpy, or some such), and then outputs the data
byte-by-byte. This, of course, has endian issues (and formatting issues
for oddball architectures such as 16-bit intel).
Any suggestions?