opIndex overload for slice not working...

Enjoys Math via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 24 22:37:13 PST 2016


class V(T) {
public:
    this() {}
    V opIndex(size_t i, size_t j) {
      writeln("Hello, foo!");
      return this;
    }
}

main() {
    auto v = new V!int();
    auto u = v[3..4];        // ERROR
}

Error:
no [] operator overload for type the_module.V!int


More information about the Digitalmars-d-learn mailing list