Dのchar[]から空白を削除するための推奨される方法は何ですか。たとえば、私が持っているdmd2.057を使用して
import std.stdio;
import std.string;
import std.algorithm;
char[] line;
int main(){
line = r"this is a line with spaces ";
line = removechars(line," ");
writeln(line);
return 0;
}
コンパイル時に、これはこのエラーを生成します:
Error: cannot implicitly convert expression ("this is a line with spaces ") of type string to char[]
Error: template std.string.removechars(S) if (isSomeString!(S)) does not match any function template declaration
Error: template std.string.removechars(S) if (isSomeString!(S)) cannot deduce template function from argument types !()(char[],string)
いくつかのグーグル検索を行ったところ、同様のエラーがバグとして報告され、 2011年6月に提出されたことがわかりましたが、それが同じものを指しているのか、別の問題を指しているのかわかりません。
一般に、文字列から特定の文字を削除し、前の文字配列の文字の順序を維持するために推奨されるアプローチは何ですか?
この場合、
assert(line == "thisisalinewithspaces")
空白文字を削除した後