Topic: list<>::merge(list<>& x)


Author: James Kuyper <kuyper@wizard.net>
Date: 1998/11/25
Raw View
Steve Chapel wrote:
>
> James Kuyper wrote:
> >
> > I think that merge() requires an ordering operator. However, there is no
> > description of what the first version of list<>::merge() uses for that
> > purpose. The second version explicitly uses 'comp'. By analogy with the
> > two versions of list<>::sort(), I suspect that the first version of
> > merge() would use operator<(), but it doesn't say so in section
> > 23.2.2.4. Should this be corrected?
>
> An ordering operator is needed to determine from which list the next
> element in the final, sorted list comes from.

That's my understanding.

> In CD2, 25.3 states that "[F]or all algorithms that take [a function
> object of type] Compare, there is a version that uses operator<
> instead."
>
> Is there a similar statement for member functions of containers?
> If not, you might have found an oversight.

I couldn't find any.

In any event, that statement is a description of the way the standard is
written. The detailed descriptions in the algorithms library always
specifies operator<() as the ordering mechanism for the version that
doesn't have a Compare template parameter. That was not done for
list<>::merge().


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Steve Chapel <schapel@utilicom.com>
Date: 1998/11/25
Raw View
James Kuyper wrote:
>
> I think that merge() requires an ordering operator. However, there is no
> description of what the first version of list<>::merge() uses for that
> purpose. The second version explicitly uses 'comp'. By analogy with the
> two versions of list<>::sort(), I suspect that the first version of
> merge() would use operator<(), but it doesn't say so in section
> 23.2.2.4. Should this be corrected?

An ordering operator is needed to determine from which list the next
element in the final, sorted list comes from.

In CD2, 25.3 states that "[F]or all algorithms that take [a function
object of type] Compare, there is a version that uses operator<
instead."

Is there a similar statement for member functions of containers?
If not, you might have found an oversight.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: AllanW@my-dejanews.com
Date: 1998/11/25
Raw View
In article <36578F0D.26486F24@wizard.net>,
  James Kuyper <kuyper@wizard.net> wrote:
> I think that merge() requires an ordering operator. However, there is no
> description of what the first version of list<>::merge() uses for that
> purpose. The second version explicitly uses 'comp'. By analogy with the
> two versions of list<>::sort(), I suspect that the first version of
> merge() would use operator<(), but it doesn't say so in section
> 23.2.2.4. Should this be corrected?

I would say so!

Paragraph 29 [which talks about sort()] states:
    Requires: operator< (for the first version, or comp (for the
        second version) defines a strict weak ordering (25.3).
I think that the comma should be a right paren; notice that the
parens are not balanced in this sentance.

Paragraph 22 [which talks about merge()] states:
    Requires: comp defines a strict weak ordering (25.3), and
        the list and the argument list are both sorted according
        to this ordering.
I think that the first part of this sentence -- everything before
the comma -- should be replaced with an exact copy of [corrected]
paragraph 29, minus the period of course.

--
AllanW@my-dejanews.com is a "Spam Magnet" -- never read.
Please reply in USENET only, sorry.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: James Kuyper <kuyper@wizard.net>
Date: 1998/11/24
Raw View
I think that merge() requires an ordering operator. However, there is no
description of what the first version of list<>::merge() uses for that
purpose. The second version explicitly uses 'comp'. By analogy with the
two versions of list<>::sort(), I suspect that the first version of
merge() would use operator<(), but it doesn't say so in section
23.2.2.4. Should this be corrected?
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]