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_STDTUPLE_HPP
7#define BOOST_PFR_DETAIL_STDTUPLE_HPP
8#pragma once
9
10#include <boost/pfr/detail/config.hpp>
11
12#include <utility> // metaprogramming stuff
13#include <tuple>
14
15#include <boost/pfr/detail/sequence_tuple.hpp>
16
17namespace boost { namespace pfr { namespace detail {
18
19template <class T, std::size_t... I>
20constexpr auto make_stdtuple_from_tietuple(const T& t, std::index_sequence<I...>) {
21 (void)t; // workaround for MSVC 14.1 `warning C4100: 't': unreferenced formal parameter`
22 return std::make_tuple(
23 boost::pfr::detail::sequence_tuple::get<I>(t)...
24 );
25}
26
27template <class T, std::size_t... I>
28constexpr auto make_stdtiedtuple_from_tietuple(const T& t, std::index_sequence<I...>) noexcept {
29 (void)t; // workaround for MSVC 14.1 `warning C4100: 't': unreferenced formal parameter`
30 return std::tie(
31 boost::pfr::detail::sequence_tuple::get<I>(t)...
32 );
33}
34
35template <class T, std::size_t... I>
36constexpr auto make_conststdtiedtuple_from_tietuple(const T& t, std::index_sequence<I...>) noexcept {
37 (void)t; // workaround for MSVC 14.1 `warning C4100: 't': unreferenced formal parameter`
38 return std::tuple<
39 std::add_lvalue_reference_t<std::add_const_t<
40 std::remove_reference_t<decltype(boost::pfr::detail::sequence_tuple::get<I>(t))>
41 >>...
42 >(
43 boost::pfr::detail::sequence_tuple::get<I>(t)...
44 );
45}
46
47}}} // namespace boost::pfr::detail
48
49#endif // BOOST_PFR_DETAIL_STDTUPLE_HPP
50

source code of boost/libs/pfr/include/boost/pfr/detail/stdtuple.hpp