| 1 | // -*- C++ -*- |
|---|---|
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP___TUPLE_TUPLE_TRANSFORM_H |
| 11 | #define _LIBCPP___TUPLE_TUPLE_TRANSFORM_H |
| 12 | |
| 13 | #include <__config> |
| 14 | |
| 15 | #include <__functional/invoke.h> |
| 16 | #include <__utility/forward.h> |
| 17 | #include <tuple> |
| 18 | |
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header |
| 21 | #endif |
| 22 | |
| 23 | _LIBCPP_PUSH_MACROS |
| 24 | #include <__undef_macros> |
| 25 | |
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | |
| 28 | #if _LIBCPP_STD_VER >= 23 |
| 29 | |
| 30 | template <class _Fun, class _Tuple> |
| 31 | _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) { |
| 32 | return std::apply( |
| 33 | [&]<class... _Types>(_Types&&... __elements) { |
| 34 | return tuple<invoke_result_t<_Fun&, _Types>...>(std::invoke(__f, std::forward<_Types>(__elements))...); |
| 35 | }, |
| 36 | std::forward<_Tuple>(__tuple)); |
| 37 | } |
| 38 | |
| 39 | #endif // _LIBCPP_STD_VER >= 23 |
| 40 | |
| 41 | _LIBCPP_END_NAMESPACE_STD |
| 42 | |
| 43 | _LIBCPP_POP_MACROS |
| 44 | |
| 45 | #endif // _LIBCPP___TUPLE_TUPLE_TRANSFORM_H |
| 46 |