From -2840182760235519465
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fbd36da46c3cc7a0
X-Google-Attributes: gidf78e5,public
From: smeyers@aristeia.com (Scott Meyers)
Subject: Re: Discussion: type_info
Date: 1999/11/24
Message-ID: <MPG.12a60bdb1a6972e79896fb@news.teleport.com>#1/1
X-Deja-AN: 552718029
X-NNTP-Posting-Host: 216.26.6.150
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <81ecdl$pq$1@nnrp1.deja.com>
X-UID: 0000000001
X-Status: $$$T
X-Complaints-To: news@teleport.com
X-Trace: news1.teleport.com 943483902 216.26.6.150 (Wed, 24 Nov 1999 14:51:42 PST)
Organization: Teleport Inc.
NNTP-Posting-Date: Wed, 24 Nov 1999 14:51:42 PST
Newsgroups: comp.std.c++
Originator: clamage@taumet


On 23 Nov 1999 16:35:38 GMT, sirwillard@my-deja.com wrote:
....
> different references.  A lot of the examples I found on DejaNews that
> used type_info within a map used the pointer, and in fact the errata
> for Item 31 of More Effective C++ by Scott Meyers recommends a simple
> std::map<std::pair<type_info*, type_info*>, HitFunctionPtr>.  So many
> people have gotten this one wrong.
....
> So you can't rely on the collating order of the pointer within the
> map.  Instead, we'll have to use the collation order of the type_info
> object itself.  A logical idea would be to simply specialize
> std::less<type_info*>.  In fact, most of the people who realized you
> couldn't use the pointer collation suggested doing just this.  However,
> in one thread it was pointed out that according to the standard this
> would produce "undefined behavior", specifically because the standard
> library impementors are free to provide their own specialization for
> any built in types, and if they did you'd violate the "one definition
> rule".  So this is out.

Just for the record, I don't think it's out for the design I sketch in
the MEC++ errata, because it's okay to specialize less for 
pair<const type_info*, const type_info*>, which is the type I propose
putting into the map.  That is, I agree that you can't specialize std::less
for a pointer type, but I believe you can specialize it for a std::pair
containing pointer types. 

Scott

-- 
Scott Meyers, Ph.D.                  smeyers@aristeia.com
Software Development Consultant      http://www.aristeia.com/
Visit http://meyerscd.awl.com/ to demo the Effective C++ CD


[ 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              ]




