int count = 0; auto d = new AnonymousDisposable({ count++; }); assert(count == 0); d.dispose(); assert(count == 1); d.dispose(); assert(count == 1);
See Implementation