[+] Added AuConstReference

This commit is contained in:
Reece Wilson 2022-04-13 09:50:34 +01:00
parent 32fa7e6e2c
commit 70d13963be

View File

@ -9,7 +9,7 @@
/**
* @brief Upcasts R-Value upcastable @param arg.
* For an L-Value equivalent hint, use AuReference
* For an L-Value equivalent hint, use AuReference
* @tparam T
* @param arg
* @return
@ -27,12 +27,26 @@ auline constexpr AuRemoveReference_t<T> &&AuMove(T &&arg) noexcept
* @param arg
* @return
*/
template <class T>
auline constexpr T &AuReference(T &arg) noexcept
template <class T, AU_TEMPLATE_ENABLE_WHEN(!AuIsRValueReference_v<T> && !AuIsLValueReference_v<T>)>
auline constexpr AuRemoveReference_t<T> &AuReference(T &arg) noexcept
{
return static_cast<T &>(arg);
}
/**
* @brief Upcasts L-Value upcastable @param arg.
* For an R-Value equivalent hint, use AuMove
* Recommended use case: specifying constant ref method overload over move counterpart
* @tparam T An expression to implicitly upcast to a constant L-value
* @param arg
* @return
*/
template <class T, AU_TEMPLATE_ENABLE_WHEN(!AuIsRValueReference_v<T> && !AuIsLValueReference_v<T>)>
auline constexpr const AuRemoveReference_t<T> &AuConstReference(T &arg) noexcept
{
return static_cast<const T &>(arg);
}
/**
* @brief Preserves R or L value without reducing; implicit AuMove or AuReference
* @tparam T An expression to implicitly upcast to an R-value