forked from boostorg/optional
Implement constexpr definitions of forward and move to replace usage of boost::move and boost::forward from the Boost.Move library. Alter tests to use std::move instead of boost::move. Remove the dependency on Boost.Move from build.jam
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
// Copyright (C) 2024 Andrzej Krzemienski.
|
|
//
|
|
// Use, modification, and distribution is subject to the Boost Software
|
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
// See http://www.boost.org/libs/optional for documentation.
|
|
//
|
|
// You are welcome to contact the author at:
|
|
// akrzemi1@gmail.com
|
|
|
|
#ifndef BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_HPP
|
|
#define BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_HPP
|
|
|
|
namespace boost {
|
|
namespace optional_detail {
|
|
|
|
// Workaround: forward and move aren't constexpr in C++11
|
|
template <class T> inline constexpr T&& forward(typename boost::remove_reference<T>::type& t) noexcept
|
|
{
|
|
return static_cast<T&&>(t);
|
|
}
|
|
|
|
template <class T> inline constexpr T&& forward(typename boost::remove_reference<T>::type&& t) noexcept
|
|
{
|
|
BOOST_STATIC_ASSERT_MSG(!boost::is_lvalue_reference<T>::value, "Can not forward an rvalue as an lvalue.");
|
|
return static_cast<T&&>(t);
|
|
}
|
|
|
|
template <class T> inline constexpr typename boost::remove_reference<T>::type&& move(T&& t) noexcept
|
|
{
|
|
return static_cast<typename boost::remove_reference<T>::type&&>(t);
|
|
}
|
|
|
|
} // namespace optional_detail
|
|
} // namespace boost
|
|
|
|
#endif
|