| 1 | /* Copyright 2023 Joaquin M Lopez Munoz. |
|---|---|
| 2 | * Distributed under the Boost Software License, Version 1.0. |
| 3 | * (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | * http://www.boost.org/LICENSE_1_0.txt) |
| 5 | * |
| 6 | * See https://www.boost.org/libs/unordered for library home page. |
| 7 | */ |
| 8 | |
| 9 | #ifndef BOOST_UNORDERED_DETAIL_FOA_TUPLE_ROTATE_RIGHT_HPP |
| 10 | #define BOOST_UNORDERED_DETAIL_FOA_TUPLE_ROTATE_RIGHT_HPP |
| 11 | |
| 12 | #include <boost/mp11/algorithm.hpp> |
| 13 | #include <boost/mp11/integer_sequence.hpp> |
| 14 | #include <tuple> |
| 15 | #include <utility> |
| 16 | |
| 17 | namespace boost{ |
| 18 | namespace unordered{ |
| 19 | namespace detail{ |
| 20 | namespace foa{ |
| 21 | |
| 22 | template<typename Tuple> |
| 23 | using tuple_rotate_right_return_type=mp11::mp_rotate_right_c< |
| 24 | typename std::remove_cv<typename std::remove_reference<Tuple>::type>::type, |
| 25 | 1 |
| 26 | >; |
| 27 | |
| 28 | template<std::size_t... Is,typename Tuple> |
| 29 | tuple_rotate_right_return_type<Tuple> |
| 30 | tuple_rotate_right_aux(mp11::index_sequence<Is...>,Tuple&& x) |
| 31 | { |
| 32 | return tuple_rotate_right_return_type<Tuple>{ |
| 33 | std::get<(Is+sizeof...(Is)-1)%sizeof...(Is)>(std::forward<Tuple>(x))...}; |
| 34 | } |
| 35 | |
| 36 | template<typename Tuple> |
| 37 | tuple_rotate_right_return_type<Tuple> tuple_rotate_right(Tuple&& x) |
| 38 | { |
| 39 | using RawTuple=typename std::remove_cv< |
| 40 | typename std::remove_reference<Tuple>::type>::type; |
| 41 | |
| 42 | return tuple_rotate_right_aux( |
| 43 | mp11::make_index_sequence<std::tuple_size<RawTuple>::value>{}, |
| 44 | std::forward<Tuple>(x)); |
| 45 | } |
| 46 | |
| 47 | } /* namespace foa */ |
| 48 | } /* namespace detail */ |
| 49 | } /* namespace unordered */ |
| 50 | } /* namespace boost */ |
| 51 | |
| 52 | #endif |
| 53 |
