I'm comparing two pointers of class typedef value_type
which are each of type T*
or char16_t
.
The compiler complains that I can't compare the two because they are distinct types:
'some_type1<char16_t>::value_type*' and 'some_type2<char16_t>::value_type*' lacks a cast
Strangely, I can't static_cast<>
between the two:
invalid static_cast from type 'some_type1<char16_t>::value_type*' to type 'char16_t*'
Does it make a difference whether I use reinterpret_cast<>
to compare or just static_cast<>
both sides to void*
?
I read somewhere that reinterpret_cast<>
is done at runtime but I'm not sure.
UPDATE
I was under the false impression that reinterpret_cast<>
was done at runtime. With further discussion I now understand that it is purely a compile-time construct.
Curiously though, it's also been demonstrated that static_cast<>
can have runtime costs where a particular object is cast into another by matching against a constructor.
For exmaple, you can cast a primitive int
to a vector with static_cast<>
. It would seem that this is true for all cases where static_cast<T>(e)
would be valid.