From: Edward Diener on
Kris Prad wrote:
> The inserter function (from msdn):
>
> template<class Container, class Iterator>
> insert_iterator<Container> inserter(
> Container& _Cont,
> Iterator _It
> );
>
> It returns an object of insert_iterator.
>
> Can't iterator type be obtained from Container type?
>
> Something like:
>
> template<class Container>
> insert_iterator<Container> inserter(
> Container& _Cont,
> typename Container::iterator _It
> );
>
> In fact insert_iterator's ctor does this.

A container has more than one type of iterator which can be used to
insert values.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Bo Persson on
Kris Prad wrote:
> The inserter function (from msdn):
>
> template<class Container, class Iterator>
> insert_iterator<Container> inserter(
> Container& _Cont,
> Iterator _It
> );
>
> It returns an object of insert_iterator.
>
> Can't iterator type be obtained from Container type?

Yes, it can. :-)

This is a "bug" in the standard, that has been fixed for the next
release.

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#561


Bo Persson





--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Pete Becker on
Kris Prad wrote:
> The inserter function (from msdn):
>
> template<class Container, class Iterator>
> insert_iterator<Container> inserter(
> Container& _Cont,
> Iterator _It
> );
>
> It returns an object of insert_iterator.
>
> Can't iterator type be obtained from Container type?
>

Of course.

> Something like:
>
> template<class Container>
> insert_iterator<Container> inserter(
> Container& _Cont,
> typename Container::iterator _It
> );
>

If that's all that was needed, that would indeed work. So there's a
strong possibility that there's more going on here than that. To find
out if that's the case, read the documentation. I'm sure that MSDN
provides more than just the declaration...

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]