#ifndef __GBLIBCPP_BITS_TUPLE_TOOLS__ #define __GBLIBCPP_BITS_TUPLE_TOOLS__ #include #include #include #include #include namespace std { template class tuple; template struct tuple_element; template using tuple_element_t = typename tuple_element::type; template struct tuple_size; template inline constexpr std::size_t tuple_size_v = tuple_size::value; template constexpr auto get(std::tuple& tpl) noexcept -> tuple_element_t>& { return tpl.template _getl(); } template constexpr auto get(std::tuple&& tpl) noexcept -> tuple_element_t>&& { return tpl.template _getr(); } template constexpr auto get(const std::tuple& tpl) noexcept -> tuple_element_t> const& { return tpl.template _getl(); } template constexpr auto get(const std::tuple&& tpl) noexcept -> tuple_element_t> const&& { return tpl.template _getr(); } namespace __helpers { template constexpr T make_from_tuple_impl(Tuple&& tpl, std::index_sequence) { return T(std::get(std::forward(tpl))...); } template > struct __to_tuple_type { using type = T; }; template struct __to_tuple_type<_T, std::reference_wrapper> { using type = std::add_lvalue_reference_t; }; template using to_tuple_type_t = typename __to_tuple_type::type; } // namespace __helpers template constexpr T make_from_tuple(Tuple&& tpl) { return __helpers::make_from_tuple_impl( std::forward(tpl), std::make_index_sequence< std::tuple_size_v>> {} ); } } #endif