|
Boost : |
From: Gary Powell (powellg_at_[hidden])
Date: 2001-12-10 13:07:26
Last I looked "any" used typeid, should it be using your "fix"?
I.e. if I store a X const, should I be able to retrieve a X volatile? (Or
have I missed something in "any"
-Yours,
-gary-
-----Original Message-----
From: David Abrahams [mailto:david.abrahams_at_[hidden]]
Sent: Sunday, December 09, 2001 2:39 PM
To: boost
Subject: [boost] RTTI
Today I discovered (to my horror) that the following are all supposed to be
identical:
typeid(X)
typeid(X const)
typeid(X volatile)
typeid(X const volatile)
typeid(X&)
typeid(X const&)
typeid(X volatile&)
typeid(X const volatile&)
This happened when one of my compilers turned out to be conforming in this
regard, and after spending quite a while trying to track the "bug" down, I
bothered to look in the standard
;-)
Since I needed all of the information to be there at runtime, I implemented
my own function
template <class T>
type_id_t type_id();
which returns a unique type_id_t value for every T.
These objects currently support everything implied by
boost::totally_ordered<type_id_t> from the operators library, and I also
wrote a stream inserter. This is going to be part of Boost.Python, but if
there is any interest, I'll be happy to submit it as a separate library
component. Oh, also: to implement it I needed is_reference_to_const<T> and
is_reference_to_volatile<T>, which I have got working without partial
specialization (thanks Mat Markus!) These could go into type_traits if
desired.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk