xref: /minix3/external/bsd/libc++/dist/libcxx/include/experimental/tuple (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// -*- C++ -*-
2*0a6a1f1dSLionel Sambuc//===----------------------------- tuple ----------------------------------===//
3*0a6a1f1dSLionel Sambuc//
4*0a6a1f1dSLionel Sambuc//                     The LLVM Compiler Infrastructure
5*0a6a1f1dSLionel Sambuc//
6*0a6a1f1dSLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
7*0a6a1f1dSLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
8*0a6a1f1dSLionel Sambuc//
9*0a6a1f1dSLionel Sambuc//===----------------------------------------------------------------------===//
10*0a6a1f1dSLionel Sambuc
11*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_EXPERIMENTAL_TUPLE
12*0a6a1f1dSLionel Sambuc#define _LIBCPP_EXPERIMENTAL_TUPLE
13*0a6a1f1dSLionel Sambuc
14*0a6a1f1dSLionel Sambuc/*
15*0a6a1f1dSLionel Sambuc    experimental/tuple synopsis
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc// C++1y
18*0a6a1f1dSLionel Sambuc
19*0a6a1f1dSLionel Sambuc#include <tuple>
20*0a6a1f1dSLionel Sambuc
21*0a6a1f1dSLionel Sambucnamespace std {
22*0a6a1f1dSLionel Sambucnamespace experimental {
23*0a6a1f1dSLionel Sambucinline namespace fundamentals_v1 {
24*0a6a1f1dSLionel Sambuc
25*0a6a1f1dSLionel Sambuc  // See C++14 20.4.2.5, tuple helper classes
26*0a6a1f1dSLionel Sambuc  template <class T> constexpr size_t tuple_size_v
27*0a6a1f1dSLionel Sambuc    = tuple_size<T>::value;
28*0a6a1f1dSLionel Sambuc
29*0a6a1f1dSLionel Sambuc  // 3.2.2, Calling a function with a tuple of arguments
30*0a6a1f1dSLionel Sambuc  template <class F, class Tuple>
31*0a6a1f1dSLionel Sambuc  constexpr decltype(auto) apply(F&& f, Tuple&& t);
32*0a6a1f1dSLionel Sambuc
33*0a6a1f1dSLionel Sambuc} // namespace fundamentals_v1
34*0a6a1f1dSLionel Sambuc} // namespace experimental
35*0a6a1f1dSLionel Sambuc} // namespace std
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc */
38*0a6a1f1dSLionel Sambuc
39*0a6a1f1dSLionel Sambuc# include <experimental/__config>
40*0a6a1f1dSLionel Sambuc
41*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 11
42*0a6a1f1dSLionel Sambuc
43*0a6a1f1dSLionel Sambuc# include <tuple>
44*0a6a1f1dSLionel Sambuc# include <utility>
45*0a6a1f1dSLionel Sambuc# include <__functional_base>
46*0a6a1f1dSLionel Sambuc
47*0a6a1f1dSLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48*0a6a1f1dSLionel Sambuc#pragma GCC system_header
49*0a6a1f1dSLionel Sambuc#endif
50*0a6a1f1dSLionel Sambuc
51*0a6a1f1dSLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_LFTS
52*0a6a1f1dSLionel Sambuc
53*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
54*0a6a1f1dSLionel Sambuctemplate <class _Tp>
55*0a6a1f1dSLionel Sambuc_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
56*0a6a1f1dSLionel Sambuc#endif
57*0a6a1f1dSLionel Sambuc
58*0a6a1f1dSLionel Sambuctemplate <class _Fn, class _Tuple, size_t ..._Id>
59*0a6a1f1dSLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
60*0a6a1f1dSLionel Sambucdecltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
61*0a6a1f1dSLionel Sambuc                                  integer_sequence<size_t, _Id...>) {
62*0a6a1f1dSLionel Sambuc    return _VSTD::__invoke(
63*0a6a1f1dSLionel Sambuc        _VSTD::forward<_Fn>(__f),
64*0a6a1f1dSLionel Sambuc        _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...
65*0a6a1f1dSLionel Sambuc    );
66*0a6a1f1dSLionel Sambuc}
67*0a6a1f1dSLionel Sambuc
68*0a6a1f1dSLionel Sambuctemplate <class _Fn, class _Tuple>
69*0a6a1f1dSLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
70*0a6a1f1dSLionel Sambucdecltype(auto) apply(_Fn && __f, _Tuple && __t) {
71*0a6a1f1dSLionel Sambuc    return _VSTD_LFTS::__apply_tuple_impl(
72*0a6a1f1dSLionel Sambuc        _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
73*0a6a1f1dSLionel Sambuc        make_index_sequence<tuple_size<typename decay<_Tuple>::type>::value>()
74*0a6a1f1dSLionel Sambuc    );
75*0a6a1f1dSLionel Sambuc}
76*0a6a1f1dSLionel Sambuc
77*0a6a1f1dSLionel Sambuc_LIBCPP_END_NAMESPACE_LFTS
78*0a6a1f1dSLionel Sambuc
79*0a6a1f1dSLionel Sambuc#endif /* _LIBCPP_STD_VER > 11 */
80*0a6a1f1dSLionel Sambuc
81*0a6a1f1dSLionel Sambuc#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */
82