Lange Fehlermeldung, kleine Ursache
Mittwoch, 19. Januar 2011 | Autor: Nico
/home/nico/code/FAnToM/src/visAlgos/StreakSurface/FStreakSurfaceAlgorithm.cc: In member function ‘void FStreakSurfaceAlgorithm::DCELtest()’: /home/nico/code/FAnToM/src/visAlgos/StreakSurface/FStreakSurfaceAlgorithm.cc:245:43: error: no match for ‘operator<<’ in ‘std::cout << ((DCEL::HalfEdge*)((DCEL::HalfEdge*)((boost::intrusive::detail::add_const_if_c::type*)x.boost::intrusive::list_iterator::operator* [with Container = boost::intrusive::list_impl, (boost::intrusive::link_mode_type)1u, boost::intrusive::default_tag, 1>, long unsigned int, true> >, bool IsConst = false, typename boost::intrusive::detail::add_const_if_c::type& = DCEL::HalfEdge&, typename boost::intrusive::detail::add_const_if_c::type = DCEL::HalfEdge]
())->DCEL::HalfEdge::getNext())->DCEL::HalfEdge::getNext())->DCEL::HalfEdge::getNext()’ /usr/include/c++/4.5/ostream:108:7: note: candidates are: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:117:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream, std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios] /usr/include/c++/4.5/ostream:127:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:165:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:169:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:173:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/bits/ostream.tcc:91:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.5/ostream:180:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/bits/ostream.tcc:105:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits] /usr/include/c++/4.5/ostream:191:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:200:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:204:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:209:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:213:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:221:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/ostream:225:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.5/bits/ostream.tcc:119:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char, _Traits = std::char_traits, std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf] /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../Fge/src/Fge_config.hh:234:22: note: std::ostream& operator<<(std::ostream&, const Fge::CameraMode&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTimeDependentTensorField.hh:133:15: note: std::ostream& operator<<(std::ostream&, const FTimeDependentTensorField&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTensorField.hh:59:22: note: std::ostream& operator<<(std::ostream&, const FTensorFieldInfo&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FCell.hh:655:10: note: std::ostream& operator<<(std::ostream&, FCell::CellType) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMBifurcation.hh:241:15: note: std::ostream& operator<<(std::ostream&, const FAMBifurcation::bifurcationType&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:485:15: note: std::ostream& operator<<(std::ostream&, const FAMSingularPoint::mainType&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:479:15: note: std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityType&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:474:15: note: std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityNature&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/FMatrixAbstract.hh:74:15: note: std::ostream& operator<<(std::ostream&, const FMatrixAbstract&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/../../common/src/FException.hh:24:15: note: std::ostream& operator<<(std::ostream&, const FException&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/FStreakSurfaceAlgorithm.cc:245:54: error: no match for ‘operator<<’ in ‘x.boost::intrusive::list_iterator::operator* [with Container = boost::intrusive::list_impl, (boost::intrusive::link_mode_type)1u, boost::intrusive::default_tag, 1>, long unsigned int, true> >, bool IsConst = false, typename boost::intrusive::detail::add_const_if_c::type& = DCEL::HalfEdge&, typename boost::intrusive::detail::add_const_if_c::type = DCEL::HalfEdge]() << std::endl’ /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../Fge/src/Fge_config.hh:234:22: note: candidates are: std::ostream& operator<<(std::ostream&, const Fge::CameraMode&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTimeDependentTensorField.hh:133:15: note: std::ostream& operator<<(std::ostream&, const FTimeDependentTensorField&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FTensorField.hh:59:22: note: std::ostream& operator<<(std::ostream&, const FTensorFieldInfo&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/FCell.hh:655:10: note: std::ostream& operator<<(std::ostream&, FCell::CellType) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMBifurcation.hh:241:15: note: std::ostream& operator<<(std::ostream&, const FAMBifurcation::bifurcationType&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:485:15: note: std::ostream& operator<<(std::ostream&, const FAMSingularPoint::mainType&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:479:15: note: std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityType&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../analysis/src/FAMSingularPoint.hh:474:15: note: std::ostream& operator<<(std::ostream&, const FAMSingularPoint::singularityNature&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/FMatrixAbstract.hh:74:15: note: std::ostream& operator<<(std::ostream&, const FMatrixAbstract&) /home/nico/code/FAnToM/src/visAlgos/StreakSurface/../../dataSet/src/../../math/src/../../common/src/FException.hh:24:15: note: std::ostream& operator<<(std::ostream&, const FException&) make[2]: *** [visAlgos/CMakeFiles/StreakSurface.dir/StreakSurface/FStreakSurfaceAlgorithm.cc.o] Error 1 make[1]: *** [visAlgos/CMakeFiles/StreakSurface.dir/all] Error 2 make: *** [all] Error 2
Keine Panik. Wichtig ist nur
245:43: error: no match for ‘operator<<’
Zeile 245 also. Mal schaun…
cout << (*x).getNext().getNext().getNext()==(*x) << endl;
Das Problem liegt in der Priorität, mit der der Compiler die verschiedenen Operatoren auswertet1. <<
wird nämlich vor ==
ausgewertet! Daher betrachtet der Compiler zuerst das <<
:
(*x) << endl;
was fehlschlägt, da für den Typ, von dem x ist, kein «-Operator definiert ist. Daher auch die Fehlermeldung.
Die Lösung besteht schlicht darin, Klammern um den Vergleich zu setzen:
cout << ( (*x).getNext().getNext().getNext()==(*x) ) << endl;
Damit weiß C++, dass der Vergleich erst mal komplett ausgewertet und erst dessen Ergebnis ausgegeben werden soll.
- Nachlesen kann man diese sogenannte Operator Precedence zum Beispiel hier http://www.cppreference.com/operator_precedence.html. In der Regel ist die Reihenfolge schon so gemacht, dass es intuitiv ist. Unter anderem wird auch das gute alte „Punktrechnung vor Strichrechnung!” beachtet (siehe Precedence 5 und 6). ↩