Topic: type_info::before() ?
Author: dag@net.dynasim.se (Dag Bruck)
Date: 1995/06/12 Raw View
In article <3r71gi$nn8@jupiter.SJSU.EDU>,
Cay Horstmann <horstman@sjsumcs.sjsu.edu> wrote:
>: To make an STL set of type_info records there must
>: be a total ordering on the records of some kind. "before()" provides
>: that.
>
>To pour salt into an open wound...has the committee considered defining
>operator< on type_info?
Type_info and type_info::before() actually predate STL. We added before()
so people could build data structures of type_info objects, which in many
cases require some sort of ordering relation.
One of the first suggestions was to name this function operator<, but we
decided to call it before() instead. The reason is that we thought that
"<" would be regarded as an ordering defined in the standard, something that
could be portably exchanged between programs, for example. This is
definitiely not the case.
With the adoption of STL, which uses operator<, there is a strong case for
renaming before() inspite of the possible confusion.
Dag Bruck
--
Dynasim AB Phone: +46 46 182500
Research Park Ideon Fax: +46 46 129879
S-223 70 Lund E-mail: Dag@Dynasim.se
Sweden
Author: maxtal@Physics.usyd.edu.au (John Max Skaller)
Date: 1995/06/07 Raw View
In article <IMMEL.95Jun5115820@fenway.centerline.com>,
Mark Immel <immel@fenway.centerline.com> wrote:
>
>bool type_info::before(const type_info& rhs);
>
> The WP says this thing returns true if one type_info is "before"
>another in the "collating sequence" which is "unspecified and may
>differ between programs." What is before() supposed to be good for?
To make an STL set of type_info records there must
be a total ordering on the records of some kind. "before()" provides
that.
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd,
81A Glebe Point Rd, GLEBE Mem: SA IT/9/22,SC22/WG21
NSW 2037, AUSTRALIA Phone: 61-2-566-2189
Author: horstman@sjsumcs.sjsu.edu (Cay Horstmann)
Date: 1995/06/08 Raw View
: To make an STL set of type_info records there must
: be a total ordering on the records of some kind. "before()" provides
: that.
: --
To pour salt into an open wound...has the committee considered defining
operator< on type_info? If not, could you suggest an easy way of making
a set<type_info>? I mean, is there an adapter that takes &type_info::before
and makes it into a comparator?
Cay
Author: immel@fenway.centerline.com (Mark Immel)
Date: 1995/06/05 Raw View
C++ Gurus --
It's my understanding that when you say:
typeid <expr>
you get an object of class type_info. I've looked at the definition
of this class in the WP library section, and am puzzled by the
presence of a method declared as:
bool type_info::before(const type_info& rhs);
The WP says this thing returns true if one type_info is "before"
another in the "collating sequence" which is "unspecified and may
differ between programs." What is before() supposed to be good for?
What is the collating sequence supposed to be in typical
implementations?
Your help is much appreicated. If you wish, you mail email me; I'll
post responses if there is interest.
--
Mark Immel
immel@centerline.com
(617) 498-3409
--
My opinions are not necessarily those of my employer.
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1995/06/05 Raw View
In article 95Jun5115820@fenway.centerline.com, immel@fenway.centerline.com (Mark Immel) writes:
>
> It's my understanding that when you say:
>
> typeid <expr>
>
> you get an object of class type_info. I've looked at the definition
>of this class in the WP library section, and am puzzled by the
>presence of a method declared as:
>
>bool type_info::before(const type_info& rhs);
>
> The WP says this thing returns true if one type_info is "before"
>another in the "collating sequence" which is "unspecified and may
>differ between programs." What is before() supposed to be good for?
It means that you can create a sorted list of (references or pointers to)
type_info objects. (You can't copy type_info objects, and typeid returns
a reference to a const object.) The order in which the objects are sorted
is system-dependent, of course.
>What is the collating sequence supposed to be in typical
>implementations?
It is unspecified. The implementor can use any method at all.
"Unspecified" means that the implementor doesn't have to tell you the
collating sequence, and doesn't even have to be consistent from
program to program.
---
Steve Clamage, stephen.clamage@eng.sun.com
Author: tony@online.tmx.com.au (Tony Cook)
Date: 1995/06/06 Raw View
Mark Immel (immel@fenway.centerline.com) wrote:
: C++ Gurus --
: It's my understanding that when you say:
: typeid <expr>
: you get an object of class type_info. I've looked at the definition
: of this class in the WP library section, and am puzzled by the
: presence of a method declared as:
: bool type_info::before(const type_info& rhs);
: The WP says this thing returns true if one type_info is "before"
: another in the "collating sequence" which is "unspecified and may
: differ between programs." What is before() supposed to be good for?
: What is the collating sequence supposed to be in typical
: implementations?
AFAIK it's meant to simply supply a total ordering for type_info
objects.
This means you can sort them, binary search them etc.
--
Tony Cook - tony@online.tmx.com.au
100237.3425@compuserve.com