STL,ostream_iterator编译不通过,代码贴出,求指导
编译环境: g++代码如下
程序代码:
1 #include <iostream> 2 #include <iterator> 3 #include <vector> 4 #include <algorithm> 5 #include <cassert> 6 using namespace std; 7 8 typedef ostream_iterator <char > os_itr; 9 10 typedef istream_iterator <char> is_itr; 11 typedef vector <char> v_itr; 12 int main () 13 { 14 is_itr input(cin),iend; 15 v_itr v1; 16 os_itr output(cout,"\n"),oend; 17 copy(input,iend,v1.begin()); 18 copy(v1.begin(),v1.end(),output); 19 char test[]="fuck"; 20 assert(*search(v1.begin(),v1.end,&test[0],&test[4]) == "f"); 21 cout<<"---------------------ok--------------------"<<endl; 22 23 return 0; 24 }
报错如下:
search_insert_isostream.cpp: In function ¡®int main()¡ˉ:
search_insert_isostream.cpp:16: ′íÎó£o¶Ô¡®std::ostream_iterator<char, char, std::char_traits<char> >::ostream_iterator()¡ˉμÄμ÷óÃûóDÆ¥ÅäμÄoˉêy
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stream_iterator.h:180: ¸½×¢£o±¸Ñ¡Îa£o std::ostream_iterator<_Tp, _CharT, _Traits>::ostream_iterator(const std::ostream_iterator<_Tp, _CharT, _Traits>&) [with _Tp = char, _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stream_iterator.h:176: ¸½×¢£o std::ostream_iterator<_Tp, _CharT, _Traits>::ostream_iterator(std::basic_ostream<_CharT, _Traits>&, const _CharT*) [with _Tp = char, _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stream_iterator.h:164: ¸½×¢£o std::ostream_iterator<_Tp, _CharT, _Traits>::ostream_iterator(std::basic_ostream<_CharT, _Traits>&) [with _Tp = char, _CharT = char, _Traits = std::char_traits<char>]
search_insert_isostream.cpp:20: ′íÎó£o¶Ô¡®search(__gnu_cxx::__normal_iterator<char*, std::vector<char, std::allocator<char> > >, <unresolved overloaded function type>, char*, char*)¡ˉμÄμ÷óÃûóDÆ¥ÅäμÄoˉêy
search_insert_isostream.cpp:16: ′íÎó£o¶Ô¡®std::ostream_iterator<char, char, std::char_traits<char> >::ostream_iterator()¡ˉμÄμ÷óÃûóDÆ¥ÅäμÄoˉêy
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stream_iterator.h:180: ¸½×¢£o±¸Ñ¡Îa£o std::ostream_iterator<_Tp, _CharT, _Traits>::ostream_iterator(const std::ostream_iterator<_Tp, _CharT, _Traits>&) [with _Tp = char, _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stream_iterator.h:176: ¸½×¢£o std::ostream_iterator<_Tp, _CharT, _Traits>::ostream_iterator(std::basic_ostream<_CharT, _Traits>&, const _CharT*) [with _Tp = char, _CharT = char, _Traits = std::char_traits<char>]
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stream_iterator.h:164: ¸½×¢£o std::ostream_iterator<_Tp, _CharT, _Traits>::ostream_iterator(std::basic_ostream<_CharT, _Traits>&) [with _Tp = char, _CharT = char, _Traits = std::char_traits<char>]
search_insert_isostream.cpp:20: ′íÎó£o¶Ô¡®search(__gnu_cxx::__normal_iterator<char*, std::vector<char, std::allocator<char> > >, <unresolved overloaded function type>, char*, char*)¡ˉμÄμ÷óÃûóDÆ¥ÅäμÄoˉêy