C-Plus-Plus

It is amaising what horrorable error messages g++ is able to generate…

error: could not convert ‘((Parser*)this)->Parser::words. std::map<_Key, _Tp, _Compare, _Alloc>::find [with _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Tp = Word*, _Compare = std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Word*> >](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(& sval))))’ to ‘bool’

The code to reproduce it looks like
if (words.find(sval)) {...}
where words is a std::map<std::string, Word*>.

The correct code is:
if (words.find(sval) == words.end()) {...}

3 Responses to “C-Plus-Plus”

  1. Alex

    I dont get a single word of it although i guess im supposed to be…

  2. Enrico Schnepel

    Well, if you would like to be supposed… 😉

    It happened while developing the Parametrisierte Datentypen in der Programmierung-software. As you don’t attend to this course – you don’t have to be supposed.

  3. alex

    i see. “glück gehabt…”

Leave a Reply

You can opt-out from Google Analytics tracking by clicking the link below. Click here to opt-out.