Suppose i don't like the name of static_cast
operator and want to wrap it in a function with a different name, say fancy_static_cast
but perfectly preserving the semantics. How should i do it? More specifically does static_cast
accept it's argument by value or by reference? Or does it depend on the argument expression? Should i provide several overloads or will something like this do the trick?
template <typename To, typename From>
To fancy_static_cast(From&& from)
{
return static_cast<To>(std::forward<From>(from));
}