Re: Cast operation or string conversion?
Victor Bazarov wrote:
A pair of size_t objects is *most likely* bigger than an unsigned int.
HI, Victor, I studied better my code and realised that I can use that
observe function only by passing the uint32 pointer to it (the *string
version does other things). So I guess now I have a more serious
problem, that of uniquely mapping this pair of (size_t size_t) to and
uint32. What do you propose to do?
Is it possible to cast
An idea is to go redefine the observe function using uint64_t instead of
uint32
observe(uint64_t* wordid);
and then convert each size_t into a uint32 and chain them into a uint64.
Does it sound reasonable?Something like this
uint64_t chain(uint32_t one, uint32_t two) {
// get two 32bit rands and concatenate
uint64_t longrand = one;
longrand <<= 32;
longrand |= two;
return longrand;
}
but I have no clue on how to get a uint32 out of a size_t and if it's
feasible.
Can you suggest other ways?
Thanks so much again
Giuseppe
You cannot dynamic_cast anything except pointers to polymorphic classes.
That means the approach you're describing is not going to work.
I would say convert your tuple into a string using hexadecimal or some
other notation and pass the pointer to that string to your 'observe'
function.
BTW, what's the reason you're passing pointers and not references?
V