Re: could list's object be used with (for_each)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 7, 2011 at 15:44, eric <cneric12lin0@xxxxxxxxx> wrote:
> 4-8.cpp:25:44: error: no matching function for call to
> ‘for_each(std::list<std::basic_string<char> >::iterator,
> std::list<std::basic_string<char> >::iterator, <unresolved overloaded
> function type>)’
>

This is due to the author forgetting that C++ headers are allowed to
include other headers.  The "write" function ends up overloaded with
another write, and for_each doesn't know which one you mean.

You can fix this by renaming the write function (perhaps to "my_write"
or similar), or by applying a cast operator to pick the overload you
want (something like "for_each(lst.begin( ), lst.end( ),
(void(*)(string const &))write);").

~ Scott

P.S.  For "why doesn't this compile?" questions, please refer to a
general C++ list/channel before asking here, as it's rarely something
GCC specific.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux