From c33708c1f99bfda566c00ed4d0894a8535701b5c Mon Sep 17 00:00:00 2001 From: typenameTea Date: Sat, 5 Oct 2024 12:47:10 +0100 Subject: [PATCH] refactor: address code review comments --- include/boost/optional/detail/optional_utility.hpp | 13 ++++++++----- include/boost/optional/optional_io.hpp | 6 +----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/boost/optional/detail/optional_utility.hpp b/include/boost/optional/detail/optional_utility.hpp index 6fd2fd2..a5ef508 100644 --- a/include/boost/optional/detail/optional_utility.hpp +++ b/include/boost/optional/detail/optional_utility.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2024 Andrzej Krzemienski. +// Copyright (C) 2024 typenameTea. // // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -7,7 +7,7 @@ // See http://www.boost.org/libs/optional for documentation. // // You are welcome to contact the author at: -// akrzemi1@gmail.com +// typenametea@gmail.com #ifndef BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_HPP #define BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_HPP @@ -16,18 +16,21 @@ namespace boost { namespace optional_detail { // Workaround: forward and move aren't constexpr in C++11 -template inline constexpr T&& forward(typename boost::remove_reference::type& t) noexcept +template +inline constexpr T&& forward(typename boost::remove_reference::type& t) noexcept { return static_cast(t); } -template inline constexpr T&& forward(typename boost::remove_reference::type&& t) noexcept +template +inline constexpr T&& forward(typename boost::remove_reference::type&& t) noexcept { BOOST_STATIC_ASSERT_MSG(!boost::is_lvalue_reference::value, "Can not forward an rvalue as an lvalue."); return static_cast(t); } -template inline constexpr typename boost::remove_reference::type&& move(T&& t) noexcept +template +inline constexpr typename boost::remove_reference::type&& move(T&& t) noexcept { return static_cast::type&&>(t); } diff --git a/include/boost/optional/optional_io.hpp b/include/boost/optional/optional_io.hpp index b9ffc25..85acfa1 100644 --- a/include/boost/optional/optional_io.hpp +++ b/include/boost/optional/optional_io.hpp @@ -63,11 +63,7 @@ operator>>(std::basic_istream& in, optional& v) { T x; in >> x; -#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES - v = std::move(x); -#else - v = x; -#endif + v = optional_detail::move(x); } else {