Format.convert problme
    grauzone 
    none at example.net
       
    Mon Apr  6 00:37:32 PDT 2009
    
    
  
Qian Xu wrote:
> grauzone wrote:
> 
>> 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);
>> }
> 
> Hi again,
> 
> I cannot compile this code 
What exactly are you doing? What do you want to do? Without knowing 
this, we can only guess. My first reply to you was also just a guess. I 
thought maybe you had a templated function, and wanted to dump a 
templated variable, or so.
Anyway, here's a complete version of my example above. It uses 
Stdout.formatln instead of Format.convert, but this shouldn't matter at all.
import tango.io.Stdout;
void main() {
     int v = 55;
     int *pv = &v;
     //pv (an int pointer) can be exchanged with v (an int),
     //and it still works
     auto i = pv;
     alias typeof(i) T;
     static if (is(T T2 : T2*)) {
         T2 i2 = *i;
         Stdout.formatln("{}", i2);
     } else {
         Stdout.formatln("{}", i);
     }
}
    
    
More information about the Digitalmars-d-learn
mailing list