2 //===----------------------------- tuple ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_EXPERIMENTAL_TUPLE
12 #define _LIBCPP_EXPERIMENTAL_TUPLE
15 experimental/tuple synopsis
22 namespace experimental {
23 inline namespace fundamentals_v1 {
25 // See C++14 20.4.2.5, tuple helper classes
26 template <class T> constexpr size_t tuple_size_v
27 = tuple_size<T>::value;
29 // 3.2.2, Calling a function with a tuple of arguments
30 template <class F, class Tuple>
31 constexpr decltype(auto) apply(F&& f, Tuple&& t);
33 } // namespace fundamentals_v1
34 } // namespace experimental
39 # include <experimental/__config>
41 #if _LIBCPP_STD_VER > 11
45 # include <__functional_base>
47 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48 #pragma GCC system_header
51 _LIBCPP_BEGIN_NAMESPACE_LFTS
53 #ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
55 _LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
58 template <class _Fn, class _Tuple, size_t ..._Id>
59 inline _LIBCPP_INLINE_VISIBILITY
60 decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
61 integer_sequence<size_t, _Id...>) {
62 return _VSTD::__invoke(
63 _VSTD::forward<_Fn>(__f),
64 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...
68 template <class _Fn, class _Tuple>
69 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
70 decltype(auto) apply(_Fn && __f, _Tuple && __t) {
71 return _VSTD_LFTS::__apply_tuple_impl(
72 _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
73 make_index_sequence<tuple_size<typename decay<_Tuple>::type>::value>()
77 _LIBCPP_END_NAMESPACE_LFTS
79 #endif /* _LIBCPP_STD_VER > 11 */
81 #endif /* _LIBCPP_EXPERIMENTAL_TUPLE */