From 70d13963bea16049091d1786f5d99233f82d782b Mon Sep 17 00:00:00 2001 From: J Reece Wilson Date: Wed, 13 Apr 2022 09:50:34 +0100 Subject: [PATCH] [+] Added AuConstReference --- Include/auROXTL/auCopyMoveUtils.hpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Include/auROXTL/auCopyMoveUtils.hpp b/Include/auROXTL/auCopyMoveUtils.hpp index 01f4b2c..2aa5e36 100644 --- a/Include/auROXTL/auCopyMoveUtils.hpp +++ b/Include/auROXTL/auCopyMoveUtils.hpp @@ -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 &&AuMove(T &&arg) noexcept * @param arg * @return */ -template -auline constexpr T &AuReference(T &arg) noexcept +template && !AuIsLValueReference_v)> +auline constexpr AuRemoveReference_t &AuReference(T &arg) noexcept { return static_cast(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 && !AuIsLValueReference_v)> +auline constexpr const AuRemoveReference_t &AuConstReference(T &arg) noexcept +{ + return static_cast(arg); +} + /** * @brief Preserves R or L value without reducing; implicit AuMove or AuReference * @tparam T An expression to implicitly upcast to an R-value