Boost logo

Boost Users :

From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2008-01-13 10:04:36


On Sun, Jan 13, 2008 at 08:40:51AM -0600, sj_at_[hidden] wrote:
>
> I'd like to provide a function with an unique identifier:
>
Why? What is it going to do with the ID? Why not make the ID a void* pointer?
And what semantics does this "unique identification" have? Once an object is
deleted, another new'd object may get its address; I can hardly qualify that
as "unique ID".

>
> I guess another question is: should I bother replacing this old-style
> cast, maybe there is a better way to approach this situation in general?
>
reinterpret_cast. although, that's long and painful to type at every function
invocation (so is the old-style cast), so I'd redefine f() as

void f(void *pv)
{
  size_t uid = reinterpret_cast<size_t>(pv);
  ...
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net