Gonçalo Rodrigues wrote:
Hi all,
Is it true that all pointer types that can be cast into void*
4.10/2
An rvalue of type "pointer to cv T,", where T is an object type,
can be converted be converted to an rvalue of "pointer to cv void".
In other words, yes, so long as your const/volatileness is preserved.
(that
is, all pointer types with the exception of pointers to functions and
pointers to members)
note: 4.11/2 footnote 52 notes that "In particular, a pointer to member
cannot be converted to a void*".
>
And does standard C++ guarantee the existence of a primitive (signed)
integer type T such that
5.2.10/4 "A pointer can be explicitly converted to any integral type
large enough to hold it. The mapping function is implementation
defined. [Note: it is intended to be unurprising to those who know the
addressing structure of the underlying machine.]"
So yes, there exists, some type, but its type is implementation defined.
Note also, that 5.2.10/5 implies the reverse conversion exists as well.
sizeof(T) == sizeof(void*)
Even assuming the answer to the precedent question is negative (as I
suspect it is), suppose that in a given platform such an integer
primitive type T exists. Does anybody know of a way to single out such
a type, via some template or whatever?
Again, see above. Implementation defined. Your best bet is with,
#ifdefs, and either manifest defines, or your own architecture specific
defines.