Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-09 17:38:57


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.

-Dave

===================================================
  David Abrahams, C++ library designer for hire
 resume: http://users.rcn.com/abrahams/resume.html

        C++ Booster (http://www.boost.org)
          email: david.abrahams_at_[hidden]
===================================================


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk