optional_utility.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (C) 2024 Ryan Malcolm Underwood.
  2. //
  3. // Use, modification, and distribution is subject to the Boost Software
  4. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/optional for documentation.
  8. //
  9. // You are welcome to contact the author at:
  10. // typenametea@gmail.com
  11. #ifndef BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_RMU_06OCT2024_HPP
  12. #define BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_RMU_06OCT2024_HPP
  13. namespace boost {
  14. namespace optional_detail {
  15. // Workaround: forward and move aren't constexpr in C++11
  16. template <class T>
  17. inline constexpr T&& forward(typename boost::remove_reference<T>::type& t) noexcept
  18. {
  19. return static_cast<T&&>(t);
  20. }
  21. template <class T>
  22. inline constexpr T&& forward(typename boost::remove_reference<T>::type&& t) noexcept
  23. {
  24. static_assert(!boost::is_lvalue_reference<T>::value, "Can not forward an rvalue as an lvalue.");
  25. return static_cast<T&&>(t);
  26. }
  27. template <class T>
  28. inline constexpr typename boost::remove_reference<T>::type&& move(T&& t) noexcept
  29. {
  30. return static_cast<typename boost::remove_reference<T>::type&&>(t);
  31. }
  32. } // namespace optional_detail
  33. } // namespace boost
  34. #endif