it seems now when trying to cover scope semantics, @safe/@system
and pure it already becomes quite unmanagable to implement
opApply properly.
Right now this is my solution:
```d
private static enum opApplyImpl = q{
int result;
foreach (string key, ref value; this.table) {
result = dg(key, value);
if (result) {
break;
}
}
return result;
};
public int opApply(scope int delegate(string, ref
TOMLValue) @safe dg) @safe {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @safe dg) @safe {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref
TOMLValue) @safe dg) @safe {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @safe dg) @safe {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @safe dg) @safe const {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @safe dg) @safe const {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref
TOMLValue) @safe pure dg) @safe pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @safe pure dg) @safe pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref
TOMLValue) @safe pure dg) @safe pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @safe pure dg) @safe pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @safe pure dg) @safe pure const {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @safe pure dg) @safe pure const {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref
TOMLValue) @system dg) @system {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @system dg) @system {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref
TOMLValue) @system dg) @system {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @system dg) @system {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @system dg) @system const {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @system dg) @system const {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref
TOMLValue) @system pure dg) @system pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @system pure dg) @system pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref
TOMLValue) @system pure dg) @system pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @system pure dg) @system pure {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, ref const
TOMLValue) @system pure dg) @system pure const {
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const
TOMLValue) @system pure dg) @system pure const {
mixin(opApplyImpl); }
```
Surely there is a better way to do this?!
Better formatted:
![formatted code](https://wfr.moe/f6PQlp.png)
(note: I don't want to use a template, this way of writing it has
the advantage that the compiler checks all different code paths
for errors, so the errors aren't delayed until someone actually
tries to iterate over my data structure)