no matching function for call to 'std::istream_iterator

Discussion in 'C++' started by eric, Jun 23, 2011.

  1. eric

    eric Guest

    Dear advance C++ programers:

    I copy book (C++ Primer 3rd chapter 17 book example text_query.C )
    can be download from
    http://comscigate.com/BookCode/cppbooks.htm
    but my g++ 4.5.2 cann't compile it
    this is the error I got
    ---------------------------------------------------------------------
    eric@eric-laptop:~/CppPrimer3/download/chap17$ g++ Query.C UserQuery.C
    TextQuery.C text_query.C
    TextQuery.C: In member function ‘void TextQuery::build_word_map()’:
    TextQuery.C:229:67: error: no matching function for call to
    ‘std::istream_iterator<std::basic_string<char>,
    int>::istream_iterator(std::ifstream&)’
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stream_iterator.h:70:7: note: candidates are:
    std::istream_iterator<_Tp, _CharT, _Traits,
    _Dist>::istream_iterator(const std::istream_iterator<_Tp, _CharT,
    _Traits, _Dist>&) [with _Tp = std::basic_string<char>, _CharT = int,
    _Traits = std::char_traits<int>, _Dist = int,
    std::istream_iterator<_Tp, _CharT, _Traits, _Dist> =
    std::istream_iterator<std::basic_string<char>, int>]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stream_iterator.h:66:7: note:
    std::istream_iterator<_Tp, _CharT, _Traits,
    _Dist>::istream_iterator(std::istream_iterator<_Tp, _CharT, _Traits,
    _Dist>::istream_type&) [with _Tp = std::basic_string<char>, _CharT =
    int, _Traits = std::char_traits<int>, _Dist = int,
    std::istream_iterator<_Tp, _CharT, _Traits, _Dist>::istream_type =
    std::basic_istream<int, std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stream_iterator.h:62:7: note:
    std::istream_iterator<_Tp, _CharT, _Traits, _Dist>::istream_iterator()
    [with _Tp = std::basic_string<char>, _CharT = int, _Traits =
    std::char_traits<int>, _Dist = int]
    In file included from /usr/local/lib/gcc/i686-pc-linux-gnu/
    4.5.2/../../../../include/c++/4.5.2/iterator:67:0,
    from TextQuery.C:2:
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stream_iterator.h: In member function ‘void
    std::istream_iterator<_Tp, _CharT, _Traits, _Dist>::_M_read() [with
    _Tp = std::basic_string<char>, _CharT = int, _Traits =
    std::char_traits<int>, _Dist = int]’:
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stream_iterator.h:93:2: instantiated from
    ‘std::istream_iterator<_Tp, _CharT, _Traits, _Dist>&
    std::istream_iterator<_Tp, _CharT, _Traits, _Dist>::eek:perator++() [with
    _Tp = std::basic_string<char>, _CharT = int, _Traits =
    std::char_traits<int>, _Dist = int, std::istream_iterator<_Tp, _CharT,
    _Traits, _Dist> = std::istream_iterator<std::basic_string<char>,
    int>]’
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stl_algobase.h:318:4: instantiated from ‘static _OI
    std::__copy_move<<anonymous>, <anonymous>, <template-parameter-1-3>
    >::__copy_m(_II, _II, _OI) [with _II =

    std::istream_iterator<std::basic_string<char>, int>, _OI =
    std::insert_iterator<std::set<std::basic_string<char>,
    std::less<std::basic_string<char> >, std::allocator<short int> > >,
    bool <anonymous> = false, bool <anonymous> = false, <template-
    parameter-1-3> = std::input_iterator_tag]’
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stl_algobase.h:404:70: instantiated from ‘_OI
    std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false, _II =
    std::istream_iterator<std::basic_string<char>, int>, _OI =
    std::insert_iterator<std::set<std::basic_string<char>,
    std::less<std::basic_string<char> >, std::allocator<short int> > >]’
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stl_algobase.h:442:39: instantiated from ‘_OI
    std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false, _II =
    std::istream_iterator<std::basic_string<char>, int>, _OI =
    std::insert_iterator<std::set<std::basic_string<char>,
    std::less<std::basic_string<char> >, std::allocator<short int> > >]’
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stl_algobase.h:474:18: instantiated from ‘_OI
    std::copy(_II, _II, _OI) [with _II =
    std::istream_iterator<std::basic_string<char>, int>, _OI =
    std::insert_iterator<std::set<std::basic_string<char>,
    std::less<std::basic_string<char> >, std::allocator<short int> > >]’
    TextQuery.C:231:65: instantiated from here
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/stream_iterator.h:119:6: error: no match for ‘operator>>’
    in ‘*((std::istream_iterator<std::basic_string<char>, int>*)this)-
    >std::istream_iterator<std::basic_string<char>, int>::_M_stream >>

    ((std::istream_iterator<std::basic_string<char>, int>*)this)-
    >std::istream_iterator<std::basic_string<char>, int>::_M_value’

    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:120:7: note: candidates are: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(std::basic_istream<_CharT,
    _Traits>::__istream_type& (*)(std::basic_istream<_CharT,
    _Traits>::__istream_type&)) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:124:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(std::basic_istream<_CharT, _Traits>::__ios_type&
    (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT =
    int, _Traits = std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >, std::basic_istream<_CharT,
    _Traits>::__ios_type = std::basic_ios<int, std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:131:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT
    = int, _Traits = std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:167:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(bool&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/istream.tcc:113:5: note:
    std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(short int&) [with _CharT = int, _Traits =
    std::char_traits<int>]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:174:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(short unsigned int&) [with _CharT = int, _Traits
    = std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/istream.tcc:158:5: note:
    std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(int&) [with _CharT = int, _Traits =
    std::char_traits<int>]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:181:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(unsigned int&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:185:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(long int&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:189:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(long unsigned int&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:194:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(long long int&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:198:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(long long unsigned int&) [with _CharT = int,
    _Traits = std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:203:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(float&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:207:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(double&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:211:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(long double&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/istream:215:7: note: std::basic_istream<_CharT,
    _Traits>::__istream_type& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(void*&) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__istream_type = std::basic_istream<int,
    std::char_traits<int> >]
    /usr/local/lib/gcc/i686-pc-linux-gnu/4.5.2/../../../../include/c++/
    4.5.2/bits/istream.tcc:203:5: note:
    std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
    _Traits>::eek:perator>>(std::basic_istream<_CharT,
    _Traits>::__streambuf_type*) [with _CharT = int, _Traits =
    std::char_traits<int>, std::basic_istream<_CharT,
    _Traits>::__streambuf_type = std::basic_streambuf<int,
    std::char_traits<int> >]
    eric@eric-laptop:~/CppPrimer3/download/chap17$
    ------------------------------------------------------------------------------------------------------------------------------------------
    that code I guess worked on some other compiler(probably Borland)
    looking any g++ experienced c++ programer's help and thanks a lot in
    advance
    /* Dear Axel, I already follow your suggestion to eliminate the 3rd
    parameter of template stack, it improve
    a lot. */
    Eric
     
    eric, Jun 23, 2011
    #1
    1. Advertising

  2. On 23 juin, 11:30, eric <> wrote:
    >   I copy book (C++ Primer 3rd chapter 17 book example text_query.C )
    > can be download fromhttp://comscigate.com/BookCode/cppbooks.htm
    > but my g++ 4.5.2 cann't compile it
    > this is the error I got
    > ---------------------------------------------------------------------
    > eric@eric-laptop:~/CppPrimer3/download/chap17$ g++ Query.C UserQuery.C
    > TextQuery.C text_query.C
    > TextQuery.C: In member function ‘void TextQuery::build_word_map()’:
    > TextQuery.C:229:67: error: no matching function for call to
    > ‘std::istream_iterator<std::basic_string<char>,
    > int>::istream_iterator(std::ifstream&)’

    [snip]
    > that code I guess worked on some other compiler(probably Borland)
    > looking any g++ experienced c++ programer's help and thanks a lot in
    > advance
    > /* Dear Axel, I already follow your suggestion to eliminate the 3rd
    > parameter of template stack, it improve
    >    a lot. */


    As a guess, I would say he didn't include the iterator header.
    Add the following line at the beginning of TextQuery.C
    #include <iterator>

    --
    Michael
     
    Michael DOUBEZ, Jun 23, 2011
    #2
    1. Advertising

  3. eric

    red floyd Guest

    On Jun 23, 2:30 am, eric <> wrote:
    > Dear advance C++ programers:
    >
    >   I copy book (C++ Primer 3rd chapter 17 book example text_query.C )
    > can be download from http://comscigate.com/BookCode/cppbooks.htm


    As far as I know, that book is not legally available for download. Or
    are you referring to the source code downloads? Again, I'm not sure
    if
    A-W has the source legally available for download anywhere except
    their site.
     
    red floyd, Jun 23, 2011
    #3
  4. eric

    mrbrklyn Guest

    On Jun 23, 12:47 pm, red floyd <> wrote:
    > On Jun 23, 2:30 am, eric <> wrote:
    >
    > > Dear advance C++ programers:

    >
    > >   I copy book (C++ Primer 3rd chapter 17 book example text_query.C )
    > > can be download fromhttp://comscigate.com/BookCode/cppbooks.htm

    >
    > As far as I know, that book is not legally available for download.  Or
    > are you referring to the source code downloads?  Again, I'm not sure
    > if
    > A-W has the source legally available for download anywhere except
    > their site.


    The copyright police. It happens to be a legal link to the source
    code on a site that seems to have been around since 1998
     
    mrbrklyn, Jun 24, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Jansson
    Replies:
    5
    Views:
    6,424
    Ivan Vecerina
    Mar 17, 2005
  2. Marcus Kwok
    Replies:
    2
    Views:
    897
    Marcus Kwok
    Dec 2, 2005
  3. Replies:
    3
    Views:
    390
  4. dragoncoder

    Problem with std::istream_iterator

    dragoncoder, Sep 18, 2006, in forum: C++
    Replies:
    8
    Views:
    516
    Jerry Coffin
    Sep 18, 2006
  5. Pradeep
    Replies:
    5
    Views:
    1,113
    =?ISO-8859-1?Q?Jens_M=FCller?=
    Oct 19, 2006
Loading...

Share This Page