[Issue 323] New: Error: need opCmp for class Bar
xs0
xs0 at xs0.com
Thu Sep 7 14:14:33 PDT 2006
Sean Kelly wrote:
> xs0 wrote:
> Ah good point. So any ideas? Personally, I'd be happy if the default
> AA used a linked-list for chaining and opEquals for comparison so this
> wasn't an issue, but that seems a foregone conclusion. I'm mostly
> concerned about providing default behavior that makes sense for the
> common case. The problem I've run into is that I have objects which
> need to be used as keys in an AA but are not inherently sortable.
Well, one possibly good solution would be to templatize AAs and remove
opCmp from Object. That way, you'd get an error when using comparison on
objects without opCmp (most other operators work that way) and the
template could test for its presence and use different implementations
for each.
Another nice consequence would be the possibility of having optimized
implementations for specific types; most probably even a single
implementation could be considerably faster, because the compiler would
know the exact type at compile-time, producing an optimized version of
code for each.
xs0
More information about the Digitalmars-d-bugs
mailing list