|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2004-12-04 20:30:39
On 12/3/04 4:59 PM, "Jonathan Turkanis" <technews_at_[hidden]> wrote:
> Attached is some non-conforming code which automatically assigns a unique
> integer id to an arbitrary type. It's based on this post by Daniel Wallin:
>
> http://lists.boost.org/MailArchives/boost/msg69842.php
[TRUNCATE]
I take that computing these IDs at compile-time is a requirement? Otherwise
you could use something like:
reinterpret_cast<unsigned>(static_cast<void const *>(&typeid(T)));
This assumes that a void-pointer can fit within an unsigned. If not, use
the appropriate type that corresponds to C-1999's "uintptr_t". (Of course
it's possible that there's _no_ integral type big enough to fit a pointer.
In that case, my plan is screwed.)
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk