Code block as template argument

Виталий Фадеев vital.fadeev at gmail.com
Tue Feb 11 15:30:35 UTC 2020


On Tuesday, 11 February 2020 at 14:58:58 UTC, Andrea Fontana 
wrote:
> On Tuesday, 11 February 2020 at 11:34:49 UTC, Ali Çehreli wrote:
>> On 2/11/20 3:14 AM, Виталий Фадеев wrote:> On Tuesday, 11 
>> February 2020 at 11:10:44 UTC, Виталий Фадеев wrote:
>>
>> > Analog C-code with macros:
>> >      #define TPL(M,D,CODE) if ( state & M && diraction = D )
>>
>>                                                ^^^^^^^^^^^^^
>> [...]
>>
>> // Option 1: Equivalent of a C macro
>> void executeMaybe(Func)(uint M, Direction D, Func func) {
>>   if ((state & M) && (direction == D)) {
>>     func();
>>   }
>> }
>>
>> [...]
>>
>> Ali
>
> The C code apparently does an assignment inside the macro.

Wow! Thank! I mass.
I was mean comparation:
Analog C-code with macros:
     #define TPL(M,D,CODE) if ( state & M && diraction == D ) CODE;
example code
     TPL( OPEN, OUT,
       {
         delete AppsWindow
         state &= !OPEN
       }
     )

It possible in D ?
How pass code block to template ?
How to solve this problem ?


Sorry. How to delete thread ?



More information about the Digitalmars-d mailing list