I'm writing a class that, assuming the answer to Are enumeration types layout compatible with their underlying type? is "yes", is layout-compatible struct kevent
but uses enum class
es for filter
, flags
, etc. with the proper underlying types for the relevant fields. It is also standard-layout (the fields are all private
and all themselves standard layout, there are no virtual
members, there are no base classes). From my reading of n3690
, I can determine that my class and struct kevent
have the same value representation, but I can't see anything in the standard that therefore allows me to reinterpret_cast
between them, even though that seems like the reasonable interpretation of "value representation". Is this technically allowed by the standard? If not, what does knowing the value representation of a type give you?
EDIT 2014/02/24 16:45 EST: In response to a comment, I should clarify that I want to reinterpret_cast
the first class to a reference to the second, as of course you can't directly reinterpret_cast
a non-pointer type to another non-pointer type.
reinterpret_cast
. But I'm not sure if there's more. – Fukienreinterpret_cast
between struct types, do you mean cast between pointers to those types and read one through a pointer to the other? – Embryreinterpret_cast
frompointer to A
topointer to B
, you canreinterpret_cast
fromA
toreference to B
. I'll update the question to explicitly mention thereference to
bit. – Elexa