http://d.hatena.ne.jp/haru-s/20080408/1207665905#c1207675760
に対する返信が長くなるのでこっちに書きます.
h は string ではない型を返したいので
uint h(string s){ return s.length; }
試しにこう定義して
import std.typetuple; void f(T...)(T args){ ReplaceAll!(string, uint, T) x; foreach (i, arg; args) { static if (is(typeof(arg) : string)) x[i] = h(arg); else x[i] = arg; } g(x); }
そうすると ReplaceAll の行で
Error: slice _x_field_0[] is not mutable Error: slice _x_field_10[] is not mutable Error: slice _x_field_11[] is not mutable
みたいなエラーが出てしまいました.
そこで試しに
ReplaceAll!(string, uint, T) x;
の T を決めうちで
ReplaceAll!(string, uint, string, uint, string) x;
に変えてみるとコンパイルも実行もできました.
f() の引数 T args のタプルに対して ReplaceAll を適用する(あるいはそれと同等のことをする)ことはできないのでしょうか?