More IndexedBy

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 22 02:52:24 PST 2015


At

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

I'm trying to implement a wrapper type that provides type-safe 
indexing and slicing via an integer-like wrapper type I call 
*Index*.

However there's something wrong implicit conversions because

     assert(jx[J(0)] == 11);

errors as

typecons_ex.d(144,14): Error: function 
typecons_ex.IndexedBy!(int[], Index!ulong).IndexedBy.opIndex is 
not callable because it is annotated with @disable
typecons_ex.d(144,14): Error: void has no value
typecons_ex.d(144,12): Error: incompatible types for 
((jx.opIndex(Index(0LU).this(0LU)._ix)) == (11)): 'void' and 'int'

I'm not sure what the problem with my design is.

I'm guessing a key line is

     alias _ix this;

in Index. Should I remove this line and suffix all references to 
I-variables in *IndexedBy* with ._ix? If so supporting index 
types (*I*) other than *Index* in *IndexedBy* needs some glue.


More information about the Digitalmars-d-learn mailing list