Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-12 10:57:14


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>

> template<class T> struct typeid_helper
> {
> static int i;
> };
>
> template<class T> int typeid_helper<T>::i;
>
> template<class T> void const * type_id()
> {
> return &typeid_helper<T>::i;
> }
>
> This doesn't work across DLLs, though. typeid() sometimes does.

Mine does, too (in fact I needed /precisely/ that functionality). It just
extends std::type_info with some decorator flags for const, volatile, and
reference. If I find a platform where type_info::before() and operator==
don't work across DLLs I'm going to start using the name() string as an
identifier. I realize that this is nonportable, but only in the most
technical sense of the word (after all, DLLs are not covered). Smoothing out
platform differences should be no problem.

-Dave


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