How to port C++ std::is_reference<T> to D ?

Q. Schroll qs.il.paperinik at gmail.com
Sat Jun 6 14:34:25 UTC 2020


On Wednesday, 13 May 2020 at 13:36:14 UTC, wjoe wrote:
> On Monday, 11 May 2020 at 19:08:09 UTC, Q. Schroll wrote:
>>[...]
>>
>> 1. You can have variables ("data members") of reference type 
>> in structs. (They work like head-const pointers; if D had 
>> head-const or at least head-const pointers, those would be 
>> practically the same, only that references cannot be null.)
>> [...]
>
>
> That's also something I don't really know how to correctly port 
> to D.
> Anyways, that was insightful. Thank you very much for your 
> explanations.

Another thing that just occurred to me is generating types. Say I 
have an AliasSeq of types. I want to generate a list of delegates 
taking all of them with all combinations of `ref`ness. Example:
     alias list = AliasSeq!(int, char, double);
I want the AliasSeq

     alias delegates = AliasSeq!(
             R delegate(    int,     char,     double),
             R delegate(ref int,     char,     double),
             R delegate(    int, ref char,     double),
             R delegate(    int,     char,     ref double),
             R delegate(ref int, ref char,     double),
             ...,
             R delegate(ref int, ref char, ref double)
         );

That would be way easier if `ref` were part of the type (like 
const/immutable/inout/shared are).


More information about the Digitalmars-d-learn mailing list