BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
On Sunday, 29 July 2012 at 12:39:13 UTC, Era Scarecrow wrote: But having them statically separated by name/type seems much more likely to be safer in the long run with reliable results. A question regarding templates. A template with different parameters is completely incompatible correct? S

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Dmitry Olshansky
On 30-Jul-12 23:50, Era Scarecrow wrote: On Sunday, 29 July 2012 at 12:39:13 UTC, Era Scarecrow wrote: But having them statically separated by name/type seems much more likely to be safer in the long run with reliable results. A question regarding templates. A template with different parame

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Philippe Sigaud
On Mon, Jul 30, 2012 at 9:50 PM, Era Scarecrow wrote: > A question regarding templates. A template with different parameters is > completely incompatible correct? Correct. They have no reason, in general, too even generate the same code: template Chameleon(T) { static if (is(T == struct))

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
On Monday, 30 July 2012 at 20:19:51 UTC, Dmitry Olshansky wrote: Not sure what you would like to accomplish here. Than an example... struct BitArray { //assume template... ref BitArray opSliceAssign(T)(const T ba, int start, int end) if ( //if T is type bitArray but only a different cha

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
On Monday, 30 July 2012 at 21:03:39 UTC, Era Scarecrow wrote: Alright... Considered a major (Maybe even blocking). http://d.puremagic.com/issues/show_bug.cgi?id=8475

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
On Monday, 30 July 2012 at 20:48:26 UTC, Philippe Sigaud wrote: Now if all that is correct, say I want to make two functions that both use X, but are not compatible, but template functions will allow it. So... I'm not sure I understand what you're trying to do. Do you mean you want a function

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Dmitry Olshansky
On 31-Jul-12 01:03, Era Scarecrow wrote: On Monday, 30 July 2012 at 20:19:51 UTC, Dmitry Olshansky wrote: Not sure what you would like to accomplish here. Than an example... You can go for simpler separation: struct BitArray{ //() - is an empty template spec ref BitArrayopSliceAssi

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
On Monday, 30 July 2012 at 21:56:20 UTC, Dmitry Olshansky wrote: You can go for simpler separation: struct BitArray{ //() - is an empty template spec ref BitArrayopSliceAssign()(const BitArray ba, int start, int end) { //two bit array can try balk mode etc. I'll give it a try, it may very

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
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 n

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Dmitry Olshansky
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 he

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
On Monday, 30 July 2012 at 22:44:21 UTC, Dmitry Olshansky wrote: Fixed : void func(bool smth)(X!(smth).XT x){ By default XT is deduced as X!(current value of smth).XT Doesn't really fix it... a.func(b); //65 - doesn't match declaration. a.func(ba); //66 //other template test

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Philippe Sigaud
On Mon, Jul 30, 2012 at 11:19 PM, Era Scarecrow wrote: >> void func(T)(X!T x) >> {} >> >> void main() >> { >> X!bool b; >> X!int i; >> func(b); >> func(i); >> } > > > Hmmm i do think that seems right... but if it contains multiple parameters, > then...? > > template X(x1, x2, x3)

Re: BitArray/BitFields - Reworking with templates

2012-07-30 Thread Era Scarecrow
On Tuesday, 31 July 2012 at 05:27:58 UTC, Philippe Sigaud wrote: No. Use a 3-params template or a tuple: void func(A,B,C)(X!(A,B,C) x) {} or void func(Ts...)(X!(Ts) x) {} I don't know how many arguments it will have (depends on how many options I give it), and I honestly don't; It should be