IFTI with D2?

Nathan Reed nathaniel.reed at gmail.com
Mon Nov 5 18:34:20 PST 2007


Frank Benoit wrote:
> The const thing makes IFTI hard.
> 
> uint searchPattern(T)( T[] arg1, T[] arg2 ){ ... }
> 
> The function shall accept mutable/const/invariant data for both arguments.
> 
> searchPattern( "abc".idup, "a".idup ); // (1) compiles
> searchPattern( "abc".dup,  "a".dup  ); // (2) compiles
> searchPattern( "abc".idup, "a".dup  ); // (3) doesn't compile
> 
> (1) and (2) will result in independant version of the function?
> 
> Is there a solution/workaround?
> Is this a compiler bug?

That's correct, isn't it?  You have the function declared as taking the 
same type T[] for both parameters, but in (3) the arguments are of 
different types.

Does it work if you do:

unit searchPattern (T,U) (T[] arg1, U[] arg2) { ... }

Thanks,
Nathan Reed



More information about the Digitalmars-d mailing list