tuple revision 287877
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 60decltype(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))... 65 ); 66} 67 68template <class _Fn, class _Tuple> 69inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 70decltype(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>() 74 ); 75} 76 77_LIBCPP_END_NAMESPACE_LFTS 78 79#endif /* _LIBCPP_STD_VER > 11 */ 80 81#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */ 82