http://d.puremagic.com/issues/show_bug.cgi?id=1961
[EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[EMAIL PROTECTED] ------- Comment #13 from [EMAIL PROTECTED] 2008-12-02 06:54 ------- Another kind of solution to this problem, more complex to create, but maybe cleaner is to have templates to extract/change the constness of types. I am not familiar with D2, so maybe what I say is already doable, or fully wrong. In particular this assumes that a type variable T contains also the constness attributes. This is not the case now (I think) otherwise things like the min example would be already correct, but I am not fully sure because the this template arguments seem to pick constness up. I am not sure I fully grasp the implications of adding constness attributes to type variables, I think that one problem could be that the matching becomes more difficult: with: T min(T)(T a,T b) then min(const(int),invariant(int)) should instantiate with T=const(int) min(invariant(int),invariant(int)) should instantiate with T=invariant(int) min(const(int),int) should instantiate min(int,int) ??? min(invariant(int),int) should not instantiate but I see not insormountable problems Then one wants functions like naked!(T) // removed eventual const/invariant from T (naked could maybe also be T.base, as .base is already used in a similar context) constness!(T) // returns an object (int?) representing the constness of T set_constness!(T,const_val) // returns the type const(naked(T)), invariant(naked(T)), naked(T) depending on const_val also strstr can be solved set_constness!(char,constness!(U)) strstr(U:char[])(U source, char[] pattern){ // .... } Using these functions (and assuming constness is ordered, which is trivial to do) one can then build something like min_constness!(...) // returning the minimal constness of its arguments max_constness!(...) // returning the maximal constness of its arguments If one also has aliases like "function" to return the argument type tuple (used in is expressions). I think that this in combination with template constraints, allows all the freedom one could possibly want. --