Mehrdad:
Notice that there are two const-related issues in the code that are literally *unsolvable* (unless you avoid const/immutable entirely, or unless you cast() -- but then your entire code would be filled with dangerous const casts...).
Casting away casts is rather dangerous in D (more than in C++), I kind of never do it. So just don't use const/immutable in such cases. Bye, bearophile