Qian Xu wrote:
Hi All,

tango.text.convert.Format provides a nice function to convert anything to string.

It works perfect except the argument is a pointer type.
It will print the address of a pointer instead of its value

For instance: --------------------------------
int* i = new int;
*i = 10;
Format.convert("{}", i); // <- the address of the pointer
----------------------------------------------

How to let it print the value instead of the address?
Because I wanna write a dump function to dump the value of any data type (also void, null)

Check if the variable is a pointer, and if yes, dereference it:

alias typeof(i) T;
static if (is(T T2 : T2*)) {
        T2 i2 = *i;
        Format.convert("{}", i2);
} else {
        Format.convert("{}", i);
}

Reply via email to