Alex Rivera | Logout

reinterpret_cast cast cost

Asked 2010-08-26T12:57:01.157
51

My understanding is that C++ reinterpret_cast and C pointer cast is a just a compile-time functionality and that it has no performance cost at all.

Is this true?

Edit
Report

1 Answer

2

reinterpret_cast does not incur runtime cost.. however you have to be careful, as every use of reinterpret_cast is implementation defined. For example, it is possible reinterpreting a char array as an int array could cause the target architecture to throw an interrupt, because different types may have different alignment rules.

Get correct first, then worry about efficiency.

answered 2010-08-26T13:06:40.397

Your Answer