I'm trying to overload operator<<
, and it drove me crazy:
std::ostream& operator<<(std::ostream & lhs, TuringMachine::TRTable& rhs){
for(auto& statePtr : rhs){
lhs << statePtr.first->getLabel().toStdString();
for(auto& charPtr: statePtr.second){
//lhs << '\t';
lhs << charPtr.first.toAscii() ;
//lhs << 'b ';
lhs << charPtr.second.getState().getLabel().toStdString() << std::endl;
}
}
return lhs;
}
TRTable
is a typedef
for std::map<State*, std::multimap<QChar, Transition>>
. State
has its label as a QString
hence the call to .toStdString()
.
In another class I call std::cout << machine->table << std::endl;
with machine
beeing a TuringMachine*
and this gives me
error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
What am I doing wrong? Why &&
?
EDIT: using g++ 4.6 and -std=c++0x