2022-04-01 04:06:53 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: auCopyMoveUtils.hpp
|
|
|
|
Date: 2022-2-1
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Upcasts R-Value upcastable @param arg.
|
2022-04-13 08:50:34 +00:00
|
|
|
* For an L-Value equivalent hint, use AuReference
|
2022-04-01 04:06:53 +00:00
|
|
|
* @tparam T
|
|
|
|
* @param arg
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
template <class T>
|
|
|
|
auline constexpr AuRemoveReference_t<T> &&AuMove(T &&arg) noexcept
|
|
|
|
{
|
|
|
|
return static_cast<AuRemoveReference_t<T> &&>(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Upcasts L-Value upcastable @param arg.
|
|
|
|
* For an R-Value equivalent hint, use AuMove
|
|
|
|
* @tparam T An expression to implicitly upcast to an L-value
|
|
|
|
* @param arg
|
|
|
|
* @return
|
|
|
|
*/
|
2022-04-13 08:50:34 +00:00
|
|
|
template <class T, AU_TEMPLATE_ENABLE_WHEN(!AuIsRValueReference_v<T> && !AuIsLValueReference_v<T>)>
|
|
|
|
auline constexpr AuRemoveReference_t<T> &AuReference(T &arg) noexcept
|
2022-04-01 04:06:53 +00:00
|
|
|
{
|
|
|
|
return static_cast<T &>(arg);
|
|
|
|
}
|
|
|
|
|
2022-04-13 08:50:34 +00:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
|
2022-04-01 04:06:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Preserves R or L value without reducing; implicit AuMove or AuReference
|
|
|
|
* @tparam T An expression to implicitly upcast to an R-value
|
|
|
|
* @param arg
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
template <class T>
|
|
|
|
auline constexpr T &&AuForward(AuRemoveReference_t<T> &arg) noexcept
|
|
|
|
{
|
|
|
|
return static_cast<T &&>(arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Preserves R or L value without reducing; implicit AuMove or AuReference
|
|
|
|
* @tparam T
|
|
|
|
* @param arg
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
template <class T>
|
|
|
|
auline constexpr T &&AuForward(AuRemoveReference_t<T> &&arg) noexcept
|
|
|
|
{
|
|
|
|
return static_cast<T &&>(arg);
|
|
|
|
}
|