I've a constructor for the Engine
class which reads in the contents of king-moves.movelist
into a std::map
using an input file stream. The function below illustrates the same:
Engine::Engine() {
std::ifstream dbFile;
dbFile.open( "../data/king-moves.movelist" );
if( !dbFile )
std::cout << "Error: Unable to read king moves" << std::endl;
else {
unsigned long long a, b;
while( true ) {
dbFile >> a >> b;
m_k_moves_db.insert( std::pair< unsigned long long, unsigned long long >( a, b ) );
if( dbFile.eof() )
break;
}
}
std::cout << m_k_moves_db.size() << std::endl;
}
The Engine
class can be minimally represented as follows:
class Engine {
private:
std::map< unsigned long long, unsigned long long > m_k_moves_db;
public:
// Constructors and other functions
};
Now when I try to print the contents of m_k_moves_db
, I'm met with the error message Error: Unable to read king moves
.
Is there anything that I'm doing wrong while reading in from the file stream?