| 1 | // Copyright (c) 2016-2024 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 | |
| 6 | #ifndef BOOST_PFR_DETAIL_RVALUE_T_HPP |
| 7 | #define BOOST_PFR_DETAIL_RVALUE_T_HPP |
| 8 | #pragma once |
| 9 | |
| 10 | #include <type_traits> |
| 11 | #include <utility> // std::enable_if_t |
| 12 | |
| 13 | // This header provides aliases rvalue_t and lvalue_t. |
| 14 | // |
| 15 | // Usage: template <class T> void foo(rvalue<T> rvalue); |
| 16 | // |
| 17 | // Those are useful for |
| 18 | // * better type safety - you can validate at compile time that only rvalue reference is passed into the function |
| 19 | // * documentation and readability - rvalue_t<T> is much better than T&&+SFINAE |
| 20 | |
| 21 | namespace boost { namespace pfr { namespace detail { |
| 22 | |
| 23 | /// Binds to rvalues only, no copying allowed. |
| 24 | template <class T |
| 25 | #ifdef BOOST_PFR_DETAIL_STRICT_RVALUE_TESTING |
| 26 | , class = std::enable_if_t<std::is_rvalue_reference<T&&>::value> |
| 27 | #endif |
| 28 | > |
| 29 | using rvalue_t = T&&; |
| 30 | |
| 31 | /// Binds to mutable lvalues only |
| 32 | |
| 33 | }}} // namespace boost::pfr::detail |
| 34 | |
| 35 | #endif // BOOST_PFR_DETAIL_RVALUE_T_HPP |
| 36 | |