範囲に関するドキュメントを読んだ後、 std.algorithm 関数は連想配列を含むコンテナで動作するはずだと思います。
しかし、以下のコードは失敗します:
double[double] freqIntensity;
foreach (complexval; resultfft)
{
freqIntensity[arg(complexval)]++;
}
minPos!("a > b")(freqIntensity);
エラーあり:
src\main.d(56): Error: template std.algorithm.minPos does not match any function template declaration. Candidates are:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(6321): std.algorithm.minPos(alias pred = "a < b", Range)(Range range) if (isForwardRange!(Range) && !isInfinite!(Range) && is(typeof(binaryFun!(pred)(range.front, range.front))))
src\main.d(56): Error: template std.algorithm.minPos(alias pred = "a < b", Range)(Range range) if (isForwardRange!(Range) && !isInfinite!(Range) && is(typeof(binaryFun!(pred)(range.front, range.front)))) cannot deduce template function from argument types !("a > b")(double[double])
src\main.d(56): Error: template instance minPos!("a > b") errors instantiating template
もちろん、繰り返したり、他のトリックを実行したりすることはできますが、C++ で行ったのと同じ過ちを犯したくありません (C++ で C コードを書くなど)。連想配列の最大値の要素を見つける最良の方法は何ですか?