Type value
    Ali Çehreli 
    acehreli at yahoo.com
       
    Tue Dec 11 01:40:08 PST 2012
    
    
  
On 12/11/2012 01:05 AM, Ali Çehreli wrote:
 > /* Fundamental types must be made differently; probably due to syntax
 > * issues. I would have expected for the following to work:
 > *
 > * return Type!index(args); // <-- compilation error
 > */
My mind must have been in C++ mode there. :) The following is not legal 
in D:
int foo()
{
     return int(42);    // not D syntax!
}
But of course the simpler code below works:
/* A generic function that can make an object of any type. */
Type!index make(size_t index, T...)(T args)
{
// ...
     } else {
         return args[0];    // simply return "the" argument
     }
}
Ali
    
    
More information about the Digitalmars-d-learn
mailing list