Void* with static_cast vs intptr_t with reinterpret_cast?

Yes, both are guaranteed to restore the original pointer value.

Yes, both are guaranteed to restore the original pointer value. The first is specified by C++11 5.2.10/5: A pointer converted to an integer of sufficient size (if any such exists on the implementation) and back to the same pointer type will have its original value; The second is specified by C++11 5.2. 9/13: A value of type pointer to object converted to “pointer to cv void� And back, possibly with different cv-qualification, shall have its original value.

There is a technical reason to prefer the second version over the first one: intptr_t is optional, but every implementation has void*.

2 intptr_t is guaranteed at least as large as the pointer. – R. Martinho Fernandes Oct 27 '11 at 14:16 @R.

MartinhoFernandes: Yes, you're right (assuming it's ::std::intptr_t); I had to dig out the C standard to check, since the C++ standard only mentions that it exists. – Mike Seymour Oct 27 '11 at 14:19 From the comments, does a function pointer qualify as a pointer type in both of these snippets? – edA-qa mort-ora-y Oct 27 '11 at 14:19 @edA-qamort-ora-y: for the first, yes; for the second, no - the static_cast is not valid.

– Mike Seymour Oct 27 '11 at 14:21 C++11 introduces intptr_t (though it has the comment //optional) after it... – edA-qa mort-ora-y Oct 27 '11 at 14:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions