Home

Lange Fehlermeldung, kleine Ursache

Mittwoch, 19. Januar 2011 | Autor:

/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

Kei­ne Panik. Wich­tig ist nur

245:43: error: no match for ‘operator<<’

Zei­le 245 also. Mal schaun…

cout << (*x).getNext().getNext().getNext()==(*x) << endl;

Das Pro­blem liegt in der Prio­ri­tät, mit der der Com­pi­ler die ver­schie­de­nen Ope­ra­to­ren aus­wer­tet1. << wird näm­lich vor == aus­ge­wer­tet! Daher betrach­tet der Com­pi­ler zuerst das <<:

(*x) << endl;

was fehl­schlägt, da für den Typ, von dem x ist, kein «-Ope­ra­tor defi­niert ist. Daher auch die Fehlermeldung.

Die Lösung besteht schlicht dar­in, Klam­mern um den Ver­gleich zu setzen:

cout << ( (*x).getNext().getNext().getNext()==(*x) ) << endl;

Damit weiß C++, dass der Ver­gleich erst mal kom­plett aus­ge­wer­tet und erst des­sen Ergeb­nis aus­ge­ge­ben wer­den soll.

  1. Nach­le­sen kann man die­se soge­nann­te Ope­ra­tor Pre­ce­dence zum Bei­spiel hier http://www.cppreference.com/operator_precedence.html. In der Regel ist die Rei­hen­fol­ge schon so gemacht, dass es intui­tiv ist. Unter ande­rem wird auch das gute alte „Punkt­rech­nung vor Strich­rech­nung!” beach­tet (sie­he Pre­ce­dence 5 und 6).
Tags »

Trackback: