String Index Support for IndexedBy

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 14 12:38:08 PDT 2015


I have implemented a type constructor [Ii]ndexedBy at

https://github.com/nordlow/justd/blob/master/typecons_ex.d#L97

restricted by

https://github.com/nordlow/justd/blob/master/typecons_ex.d#L78

See unittests below for usage.

I would now like to extend this to enable a variant usage as

     auto xs = x.indexedBy!"I"

I want this to trigger a mixin that defines a

     struct I

inside the struct IndexedBy.

But I don't know how to change the definitions of

- isIndexableBy
- [iI]ndexedBy

in order for this work.

I started by replace all template arguments

     I

with

     alias I

which I believe is the way to go to make it possible for I to 
either a type or a CT-string. But then I get lots of strange 
compiler messages that I can't figure out what to do with.

Further is my mixin attempt at

https://github.com/nordlow/justd/blob/master/typecons_ex.d#L99

in the right direction. If so do I have to turn IndexedBy into a 
template mixin?

Could someone please help me out here?


More information about the Digitalmars-d-learn mailing list