rvalue_t.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (c) 2016-2025 Antony Polukhin
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PFR_DETAIL_RVALUE_T_HPP
  6. #define BOOST_PFR_DETAIL_RVALUE_T_HPP
  7. #pragma once
  8. #if !defined(BOOST_PFR_INTERFACE_UNIT)
  9. #include <type_traits>
  10. #include <utility> // std::enable_if_t
  11. #endif
  12. // This header provides aliases rvalue_t and lvalue_t.
  13. //
  14. // Usage: template <class T> void foo(rvalue<T> rvalue);
  15. //
  16. // Those are useful for
  17. // * better type safety - you can validate at compile time that only rvalue reference is passed into the function
  18. // * documentation and readability - rvalue_t<T> is much better than T&&+SFINAE
  19. namespace boost { namespace pfr { namespace detail {
  20. /// Binds to rvalues only, no copying allowed.
  21. template <class T
  22. #ifdef BOOST_PFR_DETAIL_STRICT_RVALUE_TESTING
  23. , class = std::enable_if_t<std::is_rvalue_reference<T&&>::value>
  24. #endif
  25. >
  26. using rvalue_t = T&&;
  27. /// Binds to mutable lvalues only
  28. }}} // namespace boost::pfr::detail
  29. #endif // BOOST_PFR_DETAIL_RVALUE_T_HPP