no matching function for call to 'std::istream_iterator


E

eric

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
---------------------------------------------------------------------
[email protected]:~/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
::__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>>’
std::istream_iterator<std::basic_string<char>, int>::_M_stream >>
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> >]
[email protected]:~/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
 
Ad

Advertisements

M

Michael DOUBEZ

  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
---------------------------------------------------------------------
[email protected]:~/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>
 
R

red floyd

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.
 
Ad

Advertisements

M

mrbrklyn

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top