Tuesday
Functions
<tue/nocopy_cast.hpp>

Detailed Description

The nocopy_cast<T>() function template.

Functions

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
 

Function Documentation

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
TThe return type.
UThe type of parameter x.
Parameters
xThe value to cast.
Returns
A const reference to x if x is already of type T. static_cast<T>(x) otherwise.