BitArray/BitFields - Reworking with templates

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Jul 30 15:44:18 PDT 2012


On 31-Jul-12 02:40, Era Scarecrow wrote:
> On Monday, 30 July 2012 at 22:23:46 UTC, Era Scarecrow wrote:
>> On Monday, 30 July 2012 at 21:56:20 UTC, Dmitry Olshansky wrote:
>>> in == scope const not sure what scope buys here but couldn't hurt.
>>
>> If it can avoid making a new copy, then it likely would help. I'll
>> need to test it. I actually am not quite sure how scope works as an
>> argument; it isn't really covered in TDPL from what I recall.
>
>   Tests with 'in' doesn't help, only ref and catching a temporary seem
> to prevent postblits.
>
>
>
> Also the empty template doesn't work, somehow I'm not surprised...
>
> template X(bool something) {
>   struct XT {

Fixed :

>     void func(bool smth)(X!(smth).XT x){

By default XT is deduced as X!(current value of smth).XT

>          writeln("XT template called: typeID:", typeid(x));
>     }
>   }
> }
>
> alias X!true.XT A;
> alias X!false.XT B;
>
> A a, b;
> B ba;
>
> a.func(b); //passes
> a.func(ba);
>
> Error: template test.X!(true).XT.func does not match any function
> template declaration
> Error: template test.X!(true).XT.func() cannot deduce template function
> from argument types !()(XT)


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list