BitArray/BitFields - Reworking with templates

Era Scarecrow rtcvb32 at yahoo.com
Mon Jul 30 15:40:18 PDT 2012


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 {
    void func()(XT x){
         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)


More information about the Digitalmars-d-learn mailing list