Can static_cast to same type introduce runtime overhead?
问题 I have a structure template that takes two types ( T and S ), and at some point uses a static_cast to convert from one type to the other. It is often the case that T and S are the same type. A simplified example of the setup: template <typename T, typename S = T> struct foo { void bar(T val) { /* ... */ some_other_function(static_cast<S>(val)); /* ... */ } }; In the case that S is the same class as T , does or can the static_cast introduce extra overhead, or is it a null operation which will