Deduct and return class type

Виталий Фадеев vital.fadeev at gmail.com
Sat Jan 23 07:17:38 UTC 2021


On Saturday, 23 January 2021 at 05:54:09 UTC, Виталий Фадеев 
wrote:
> On Saturday, 23 January 2021 at 05:39:18 UTC, Виталий Фадеев 
> wrote:
>> Context:
>>     data + GUI List
>>
>> Goal:
>>     auto list = new List( data );

I want 'this( T )( T data )' deduction:

     class A( T )
     {
         this( T )( T data )
         {
             // ...
         }
     }

What way to implement this ?

Rules:
    1. if class is template
    2. if ctor is template
    3. if ctor template arg have same name with class template arg 
name (example: T )
    4. deduct T of ctor
    5. set type T for class template ( or put in suggestion queue )

Verify, please.

Where source ?
Where deduction implementation ?



More information about the Digitalmars-d-learn mailing list