The nocopy_cast<T>()
function template.
|
template<typename T , typename U > |
constexpr std::conditional_t< std::is_same< T, U >::value, const T &, T > | tue::nocopy_cast (const U &x) noexcept |
| Casts x to type T , avoiding a copy if possible. More...
|
|
template<typename T , typename U > |
void | tue::nocopy_cast (U &&x)=delete |
|
template<typename T , typename U >
constexpr std::conditional_t<std::is_same<T, U>::value, const T&, T> tue::nocopy_cast |
( |
const U & |
x | ) |
|
|
inlinenoexcept |
Casts x
to type T
, avoiding a copy if possible.
- Template Parameters
-
T | The return type. |
U | The type of parameter x . |
- Parameters
-
- Returns
- A const reference to
x
if x
is already of type T
. static_cast<T>(x)
otherwise.