だから私は関数を持っています、ここではと呼ばれるKaylesPosition
クラスがあります:vector<int>
piles
// Produces a key to compare itself to equivalent positions
std::string KaylesPosition::makeKey(){
std::vector<int> temp(piles.size());
for (int i = 0;i<piles.size();i++){
temp[i]=piles[i];
}
std::sort (temp.begin(),temp.end());
std::string key = "" + temp.at(0);
for (int i=1 ; i<temp.size() ; i++){
key.push_back('.');
key.push_back(temp.at(i));
}
return key;
}
私の期待する出力はpiles
、ピリオドで区切られた、順番にすべての要素である必要があります。ただし、代わりにkey
「_M_range_check」として返されます。std :: string.append()を使用してこれを試しましたが、空の文字列またはピリオドが表示されます。この関数ですべての値の文字列を期待どおりに返すにはどうすればよいpiles
ですか?