• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// -*- C++ -*-
2//===----------------------------- tuple ----------------------------------===//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_EXPERIMENTAL_TUPLE
12#define _LIBCPP_EXPERIMENTAL_TUPLE
13
14/*
15    experimental/tuple synopsis
16
17// C++1y
18
19#include <tuple>
20
21namespace std {
22namespace experimental {
23inline namespace fundamentals_v1 {
24
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;
28
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);
32
33} // namespace fundamentals_v1
34} // namespace experimental
35} // namespace std
36
37 */
38
39# include <experimental/__config>
40
41#if _LIBCPP_STD_VER > 11
42
43# include <tuple>
44# include <utility>
45# include <__functional_base>
46
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48#pragma GCC system_header
49#endif
50
51_LIBCPP_BEGIN_NAMESPACE_LFTS
52
53#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
54template <class _Tp>
55_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
56#endif
57
58template <class _Fn, class _Tuple, size_t ..._Id>
59inline _LIBCPP_INLINE_VISIBILITY
60_LIBCPP_CONSTEXPR_AFTER_CXX11
61decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
62                                  integer_sequence<size_t, _Id...>) {
63    return _VSTD::__invoke_constexpr(
64        _VSTD::forward<_Fn>(__f),
65        _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...
66    );
67}
68
69template <class _Fn, class _Tuple>
70inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
71decltype(auto) apply(_Fn && __f, _Tuple && __t) {
72    return _VSTD_LFTS::__apply_tuple_impl(
73        _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
74        make_index_sequence<tuple_size<typename decay<_Tuple>::type>::value>()
75    );
76}
77
78_LIBCPP_END_NAMESPACE_LFTS
79
80#endif /* _LIBCPP_STD_VER > 11 */
81
82#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */
83