int count = 0; struct TestObserver { void put(int n) { count++; } } auto c1 = new CompositeObserver!int; c1.put(0); auto o1 = observerObject!int(TestObserver()); auto c2 = c1.add(o1); c1.put(0); assert(count == 0); c2.put(0); assert(count == 1); auto c3 = c2.add(observerObject!int(TestObserver())); c3.put(0); assert(count == 3); auto c4 = c3.remove(o1); c4.put(0); assert(count == 4);