Dealing with type information loss in Parameters Fields and Return type

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 17 03:27:10 PDT 2016


On Sunday, 17 April 2016 at 10:22:00 UTC, Anonymouse wrote:
> On Sunday, 17 April 2016 at 10:12:29 UTC, Nicholas Wilson wrote:
>> So currently there is a loss of information when Parameters 
>> Fields and Return type.
>> i.e. assuming 64 bits
>> size_t foo(ptrdiff_t) {};
>>
>> writeln(ReturnType!foo); // prints ulong
>>
>> Is there any way to get the types as (tuples of) strings of 
>> the the types as they are in the source file?
>>
>> auto foos = StringReturnType!foo;
>> static assert(typeof(foos) == string);
>> pramga(msg, foos); // available at CT, prints size_t
>
> Correct me if I'm wrong but size_t is just an alias of ulong 
> (assuming 64 bits), so they're the exact same thing. A rose by 
> any other name etc.

not on 32bits its not. Also consider a Platform specific alias. 
The end result is that it is not portable.


More information about the Digitalmars-d-learn mailing list