static_cast<T>(e)
is equivalent to creating an invented temporary variable v in the following way:
T v(e); //where T is an arbitrary type and e is an arbitrary expression.
The runtime cost of a static_cast is exactly the cost of the above statement
More Related Contents:
- convert static_castmalloc/free to new/delete
- Why use static_cast(x) instead of (int)x?
- Should I use static_cast or reinterpret_cast when casting a void* to whatever
- What is the difference between static_cast and C style casting?
- When does a constexpr function get evaluated at compile time?
- Can placement new for arrays be used in a portable way?
- Is sizeof in C++ evaluated at compilation time or run time?
- In what ways do C++ exceptions slow down code when there are no exceptions thown?
- Is it possible to create a function dynamically, during runtime in C++?
- Casting double array to a struct of doubles
- Does “undefined behaviour” extend to compile-time?
- Why can’t static_cast be used to down-cast when virtual inheritance is involved?
- How much overhead is there in calling a function in C++?
- Why can’t I static_cast between char * and unsigned char *?
- C++ When should we prefer to use a two chained static_cast over reinterpret_cast
- Why do we have reinterpret_cast in C++ when two chained static_cast can do its job?
- CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
- Constants and compiler optimization in C++
- Setting the internal buffer used by a standard stream (pubsetbuf)
- C++: what regex library should I use? [closed]
- C++ system() not working when there are spaces in two different parameters
- How to detect existence of a class using SFINAE?
- delete[] an array of objects
- Is there any standard way of embedding resources into Linux executable image? [duplicate]
- C++ When is it OK to extend the `std` namespace?
- When would anyone use a union? Is it a remnant from the C-only days?
- How to detect whether Windows is shutting down or restarting
- Cross Platform Way to make a directory including subfolders?
- How to detect Text Area from image?
- Can I call memcpy() and memmove() with “number of bytes” set to zero?