解決策が見つからないコードに問題があります。
void Buffer::printAllBoards()
{
std::cout << "Total " << boards_.size() << " boards." << std::endl;
std::map<PlayBoard, InvVertex*>::iterator itr;
for (itr = boards_.begin(); itr != boards_.end(); ++itr)
{
std::cout << "the distance is " << distance(boards_.begin(), boards_.end()) << std::endl;
//PlayBoard board = itr->first;
//board.printBoard();
}
}
board_ は Buffer のメンバー変数であり、型 std::map< PlayBoard, InvVertex* > を持ちます。
コードのこの部分のプログラムの出力は次のとおりです。
Total 9 boards.
the distance is 2
the distance is 2
マップに 9 つの要素を追加するため、最初の行は明らかです。しかし、反復子を使用すると、begin または end 関数のいずれかが正しい値を持たないため、そのうちの 2 つしかアクセスできません。
誰かがそれに対する解決策を持っていますか?
回答ありがとうございます。
ここの tar.gz でダウンロードとしてコードを提供しました: http://www.file-upload.net/download-7931142/invers.tar.gz.html