Thread View: comp.std.c++
4 messages
4 total messages
Started by Marian Hellema
Wed, 01 Nov 1995 18:36
Q: Items in associative containers need == and < ?
Author: Marian Hellema
Date: Wed, 01 Nov 1995 18:36
Date: Wed, 01 Nov 1995 18:36
22 lines
1181 bytes
1181 bytes
I am using ObjectSpace's STL<Toolkit>. The ObjectSpace documentation states: "All the items that are stored in associative containers must be comparable using == and <" I have not been able to find a confirmation for this rule in the standard working paper. Can someone clear this up for me? Thanks, Marian -- ---------------------------------------------------------------------- Marian Hellema AT Computing, UNIX training and consultancy email: marian@atcmp.nl P.O. Box 1428, 6501 BK Nijmegen phone: +31 24 3527225 the Netherlands --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Q: Items in associative containers need == and < ?
Author: Matt Austern
Date: Wed, 01 Nov 1995 19:29
Date: Wed, 01 Nov 1995 19:29
39 lines
2383 bytes
2383 bytes
In article <477o7e$5pd@info.uci.kun.nl> Marian Hellema <marian@atcmp.nl> writes: > The ObjectSpace documentation states: > "All the items that are stored in associative containers must be > comparable using == and <"> > I have not been able to find a confirmation for this rule in the > standard working paper. Can someone clear this up for me? All of the associative containers in the STL require that a comparison function be defined for items in the container, but it does not necessarily have to use operator <. (See section 23.3 of the draft standard.) One of the template parameters of the associative containers is a comparison function object used to compare items in the container. By default the comparison object is less<Key>, meaning that it uses operator <, but you may provide a different type if you want to store objects for which operator < is undefined. (Note, incidentally, that you may pass a comparison object in the container's constructor: each container may have its own comparison object. This argument defaults to Compare(), which, again, defaults to less<Key>().) It's still true that you must define an ordering for whatever type you're putting in the container; you simply aren't required to use operator <. Associative containers that you can use for unordered keys would also be useful, but a proposal to add them to the standard was rejected. -- Matt Austern He showed his lower teeth. "We matt@physics.berkeley.edu all have flaws," he said, "and http://dogbert.lbl.gov/~matt mine is being wicked." --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Q: Items in associative containers need == and < ?
Author: Ajay Kamdar
Date: Thu, 02 Nov 1995 16:06
Date: Thu, 02 Nov 1995 16:06
29 lines
1836 bytes
1836 bytes
In article <477o7e$5pd@info.uci.kun.nl>, Marian Hellema <marian@atcmp.nl> wrote: > >I am using ObjectSpace's STL<Toolkit>. >The ObjectSpace documentation states: >"All the items that are stored in associative containers must be >comparable using == and <" > >I have not been able to find a confirmation for this rule in the >standard working paper. Can someone clear this up for me? My reading of 23.1.3 of the April WP indicated that operator == should not be required by the associative containers. I havent' checked the September WP, but I don't expect this non-requirement to have changed. When I submitted a bug report to ObjectSpace against version 1.1.0 of the library, I was told that they simply hadn't caught up with the WP yet. The document accompanying version 1.2 of the library also specifies the same requirement. Looks like they still haven't caught up with the WP. One of the few annoying inconsistencies in an otherwise very good implementation of STL. -- Ajay Kamdar | Email: ajay@lehman.com | Standard Disclaimer Lehman Brothers | Phone: (201) 524-5048 | [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: Q: Items in associative containers need == and < ?
Author: Ajay Kamdar
Date: Fri, 03 Nov 1995 19:23
Date: Fri, 03 Nov 1995 19:23
15 lines
1044 bytes
1044 bytes
In article <47ai5s$54b@jabba.lehman.com>, Ajay Kamdar <ajay@lehman.com> wrote: >My reading of 23.1.3 of the April WP indicated that operator == should >not be required by the associative containers. Typo: That should have been 23.1.2.3. -- Ajay Kamdar | Email: ajay@lehman.com | Standard Disclaimer Lehman Brothers | Phone: (201) 524-5048 | --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads