BitArray new design
    Dmitry Olshansky 
    dmitry.olsh at gmail.com
       
    Thu Jan 10 12:11:36 PST 2013
    
    
  
10-Jan-2013 01:47, Era Scarecrow пишет:
> On Wednesday, 9 January 2013 at 21:16:37 UTC, Era Scarecrow wrote:
>>  Hmm as I'm thinking about it more, a mixin for BitString may be better..
>
Overall direction is good (I mean separation of ranges/containers). I'll 
post more comments once I think it through.The minor detail is that 
BitString sounds like a individual container whereas it's a "binary view 
of packed bools".
>   I'm having troubles trying to understand why this won't work. Anyone
> clarify?
>
>
>
> mixin template BitString()
> {
>      struct BitString {
>          size_t opIndex(int i) {
> //Error: this for bulkRaw needs to be type BitArray not type BitString
>              return bulkRaw[i];
>          }
>      }
> }
You want to mixin a definition of a inner struct BitString into each bit 
array?
Or include all of functions of BitString to be mixed into BitArray?
If the latter then:
  mixin template BitString()
  {
       size_t opIndex(int i) {
               return bulkRaw[i];
           }
//....
  }
i.e. no struct it's just a template.
> struct BitArray {
>      mixin BitString;
>      size_t[] bulkRaw;
>      BitString ba;
> }
>
-- 
Dmitry Olshansky
    
    
More information about the Digitalmars-d-learn
mailing list