Click here to Skip to main content
15,915,093 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Problems with HTMLElementEvents2 Pin
stereo16-Feb-03 5:57
stereo16-Feb-03 5:57 
GeneralRe: Problems with HTMLElementEvents2 Pin
Xavyer16-Feb-03 8:04
Xavyer16-Feb-03 8:04 
GeneralQuestion about allocate of STL. Pin
George213-Feb-03 1:55
George213-Feb-03 1:55 
GeneralRe: Question about allocate of STL. Pin
markkuk13-Feb-03 2:24
markkuk13-Feb-03 2:24 
GeneralSinking events... Pin
LukeV12-Feb-03 3:25
LukeV12-Feb-03 3:25 
GeneralRe: Sinking events... Pin
LukeV12-Feb-03 4:37
LukeV12-Feb-03 4:37 
GeneralRe: Sinking events... Pin
LukeV12-Feb-03 11:45
LukeV12-Feb-03 11:45 
GeneralQuestion about front_inserter of STL. Pin
George212-Feb-03 2:56
George212-Feb-03 2:56 
Hi, everyone!

Here is a sample of the usage of inserter of STL.
When compiling it with VC6.0, some error occur.

I have added the source codes and related error
messages below.

Source:

--------
#include <iostream>
#include <vector>
#include <deque>
#include <fstream>
#include <algorithm>

using namespace std;


template <class Container>
back_insert_iterator<Container> back_inserter(Container& x) {
return back_insert_iterator<Container>(x);
}

template <class Container>
front_insert_iterator<Container> front_inserter(Container& x) {
return front_insert_iterator<Container>(x);
}

template <class Container, class Iterator>
insert_iterator<Container> inserter(Container& x, Iterator i) {
return insert_iterator<Container>(x, Container::iterator(i));
}

int main()
{
ifstream f ("c:\\example"); // file example: 1 3
deque<int> d;
copy (istream_iterator<int>(f),
istream_iterator<int>(),
back_inserter(d) );

vector<int> w (2,7);
copy (w.begin(), w.end(), front_inserter (d) );

insert_iterator<deque<int> > i = inserter (d, ++d.begin() );
*i = 9;

return 1;
}
--------

Error messages:
--------
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(31) : error C2667: 'back_inserter' : none of 2 overload

have a best conversion
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(31) : error C2668: 'back_inserter' : ambiguous call to

overloaded function
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(34) : error C2667: 'front_inserter' : none of 2 overload

have a best conversion
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(34) : error C2668: 'front_inserter' : ambiguous call to

overloaded function
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(36) : error C2667: 'inserter' : none of 2 overload have a

best conversion
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(36) : error C2668: 'inserter' : ambiguous call to

overloaded function
C:\Program Files\Microsoft Visual Studio\MyProjects\testI\testI.cpp(36) : error C2512: 'insert_iterator<class

std::deque<int,class std::allocator<int> > >' : no appropriate default constructor available
Error executing cl.exe.
--------


Thanks in advance,
George


GeneralRe: Question about front_inserter of STL. Pin
Joaquín M López Muñoz12-Feb-03 6:47
Joaquín M López Muñoz12-Feb-03 6:47 
GeneralRe: Question about front_inserter of STL. Pin
George212-Feb-03 13:32
George212-Feb-03 13:32 
GeneralQuestion about reverse_iterator. Pin
George212-Feb-03 2:21
George212-Feb-03 2:21 
GeneralRe: Question about reverse_iterator. Pin
Joaquín M López Muñoz12-Feb-03 2:26
Joaquín M López Muñoz12-Feb-03 2:26 
GeneralRe: Question about reverse_iterator. Pin
George212-Feb-03 2:35
George212-Feb-03 2:35 
GeneralQuestion about iterator of STL. Pin
George212-Feb-03 1:43
George212-Feb-03 1:43 
GeneralRe: Question about iterator of STL. Pin
Joaquín M López Muñoz12-Feb-03 2:07
Joaquín M López Muñoz12-Feb-03 2:07 
GeneralRe: Question about iterator of STL. Pin
George212-Feb-03 2:11
George212-Feb-03 2:11 
GeneralRe: Question about iterator of STL. Pin
Joaquín M López Muñoz12-Feb-03 2:19
Joaquín M López Muñoz12-Feb-03 2:19 
GeneralRe: Question about iterator of STL. Pin
George212-Feb-03 2:22
George212-Feb-03 2:22 
GeneralMFC And STL Pin
super11-Feb-03 3:46
professionalsuper11-Feb-03 3:46 
GeneralRe: MFC And STL Pin
Joaquín M López Muñoz11-Feb-03 7:54
Joaquín M López Muñoz11-Feb-03 7:54 
GeneralRe: MFC And STL Pin
Tim Smith11-Feb-03 8:43
Tim Smith11-Feb-03 8:43 
GeneralQuestion about STL stack Pin
George211-Feb-03 0:24
George211-Feb-03 0:24 
GeneralRe: Question about STL stack Pin
Stuart Dootson11-Feb-03 1:52
professionalStuart Dootson11-Feb-03 1:52 
GeneralRe: Question about STL stack Pin
George211-Feb-03 1:58
George211-Feb-03 1:58 
GeneralExcluding implemented interfaces from the typelib Pin
Nick Blumhardt10-Feb-03 19:20
Nick Blumhardt10-Feb-03 19:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.