stdtuple.hpp 1.7 KB

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