blob: 2bc2d2c1466f456c97caa9e0599832ca7742fc78 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_FUNCTIONAL_BASE
12#define _LIBCPP_FUNCTIONAL_BASE
13
14#include <__config>
15#include <type_traits>
16#include <typeinfo>
17#include <exception>
18
Howard Hinnant08e17472011-10-17 20:05:10 +000019#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +000021#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25template <class _Arg, class _Result>
Howard Hinnant83eade62013-03-06 23:30:19 +000026struct _LIBCPP_TYPE_VIS unary_function
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000027{
28 typedef _Arg argument_type;
29 typedef _Result result_type;
30};
31
32template <class _Arg1, class _Arg2, class _Result>
Howard Hinnant83eade62013-03-06 23:30:19 +000033struct _LIBCPP_TYPE_VIS binary_function
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000034{
35 typedef _Arg1 first_argument_type;
36 typedef _Arg2 second_argument_type;
37 typedef _Result result_type;
38};
39
Howard Hinnant83eade62013-03-06 23:30:19 +000040template <class _Tp> struct _LIBCPP_TYPE_VIS hash;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000041
42template <class _Tp>
43struct __has_result_type
44{
45private:
Howard Hinnant9c0df142012-10-30 19:06:59 +000046 struct __two {char __lx; char __lxx;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000047 template <class _Up> static __two __test(...);
48 template <class _Up> static char __test(typename _Up::result_type* = 0);
49public:
50 static const bool value = sizeof(__test<_Tp>(0)) == 1;
51};
52
Marshall Clowff464092013-07-29 14:21:53 +000053#if _LIBCPP_STD_VER > 11
54template <class _Tp = void>
55#else
Howard Hinnant3fadda32012-02-21 21:02:58 +000056template <class _Tp>
Marshall Clowff464092013-07-29 14:21:53 +000057#endif
Howard Hinnant83eade62013-03-06 23:30:19 +000058struct _LIBCPP_TYPE_VIS less : binary_function<_Tp, _Tp, bool>
Howard Hinnant3fadda32012-02-21 21:02:58 +000059{
60 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
61 {return __x < __y;}
62};
63
Marshall Clowff464092013-07-29 14:21:53 +000064#if _LIBCPP_STD_VER > 11
65template <>
66struct _LIBCPP_TYPE_VIS less<void>
67{
68 template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY
69 auto operator()(_T1&& __t, _T2&& __u) const
70 { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
71};
72#endif
73
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000074#ifdef _LIBCPP_HAS_NO_VARIADICS
75
76#include <__functional_base_03>
77
78#else // _LIBCPP_HAS_NO_VARIADICS
79
80// __weak_result_type
81
82template <class _Tp>
83struct __derives_from_unary_function
84{
85private:
Howard Hinnant9c0df142012-10-30 19:06:59 +000086 struct __two {char __lx; char __lxx;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000087 static __two __test(...);
Howard Hinnant99968442011-11-29 18:15:50 +000088 template <class _Ap, class _Rp>
89 static unary_function<_Ap, _Rp>
90 __test(const volatile unary_function<_Ap, _Rp>*);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000091public:
92 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
93 typedef decltype(__test((_Tp*)0)) type;
94};
95
96template <class _Tp>
97struct __derives_from_binary_function
98{
99private:
Howard Hinnant9c0df142012-10-30 19:06:59 +0000100 struct __two {char __lx; char __lxx;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000101 static __two __test(...);
Howard Hinnant99968442011-11-29 18:15:50 +0000102 template <class _A1, class _A2, class _Rp>
103 static binary_function<_A1, _A2, _Rp>
104 __test(const volatile binary_function<_A1, _A2, _Rp>*);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000105public:
106 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
107 typedef decltype(__test((_Tp*)0)) type;
108};
109
110template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
111struct __maybe_derive_from_unary_function // bool is true
112 : public __derives_from_unary_function<_Tp>::type
113{
114};
115
116template <class _Tp>
117struct __maybe_derive_from_unary_function<_Tp, false>
118{
119};
120
121template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
122struct __maybe_derive_from_binary_function // bool is true
123 : public __derives_from_binary_function<_Tp>::type
124{
125};
126
127template <class _Tp>
128struct __maybe_derive_from_binary_function<_Tp, false>
129{
130};
131
132template <class _Tp, bool = __has_result_type<_Tp>::value>
133struct __weak_result_type_imp // bool is true
134 : public __maybe_derive_from_unary_function<_Tp>,
135 public __maybe_derive_from_binary_function<_Tp>
136{
137 typedef typename _Tp::result_type result_type;
138};
139
140template <class _Tp>
141struct __weak_result_type_imp<_Tp, false>
142 : public __maybe_derive_from_unary_function<_Tp>,
143 public __maybe_derive_from_binary_function<_Tp>
144{
145};
146
147template <class _Tp>
148struct __weak_result_type
149 : public __weak_result_type_imp<_Tp>
150{
151};
152
153// 0 argument case
154
Howard Hinnant99968442011-11-29 18:15:50 +0000155template <class _Rp>
156struct __weak_result_type<_Rp ()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000157{
Howard Hinnant99968442011-11-29 18:15:50 +0000158 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000159};
160
Howard Hinnant99968442011-11-29 18:15:50 +0000161template <class _Rp>
162struct __weak_result_type<_Rp (&)()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000163{
Howard Hinnant99968442011-11-29 18:15:50 +0000164 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000165};
166
Howard Hinnant99968442011-11-29 18:15:50 +0000167template <class _Rp>
168struct __weak_result_type<_Rp (*)()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000169{
Howard Hinnant99968442011-11-29 18:15:50 +0000170 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000171};
172
173// 1 argument case
174
Howard Hinnant99968442011-11-29 18:15:50 +0000175template <class _Rp, class _A1>
176struct __weak_result_type<_Rp (_A1)>
177 : public unary_function<_A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000178{
179};
180
Howard Hinnant99968442011-11-29 18:15:50 +0000181template <class _Rp, class _A1>
182struct __weak_result_type<_Rp (&)(_A1)>
183 : public unary_function<_A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000184{
185};
186
Howard Hinnant99968442011-11-29 18:15:50 +0000187template <class _Rp, class _A1>
188struct __weak_result_type<_Rp (*)(_A1)>
189 : public unary_function<_A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000190{
191};
192
Howard Hinnant99968442011-11-29 18:15:50 +0000193template <class _Rp, class _Cp>
194struct __weak_result_type<_Rp (_Cp::*)()>
195 : public unary_function<_Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000196{
197};
198
Howard Hinnant99968442011-11-29 18:15:50 +0000199template <class _Rp, class _Cp>
200struct __weak_result_type<_Rp (_Cp::*)() const>
201 : public unary_function<const _Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000202{
203};
204
Howard Hinnant99968442011-11-29 18:15:50 +0000205template <class _Rp, class _Cp>
206struct __weak_result_type<_Rp (_Cp::*)() volatile>
207 : public unary_function<volatile _Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000208{
209};
210
Howard Hinnant99968442011-11-29 18:15:50 +0000211template <class _Rp, class _Cp>
212struct __weak_result_type<_Rp (_Cp::*)() const volatile>
213 : public unary_function<const volatile _Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000214{
215};
216
217// 2 argument case
218
Howard Hinnant99968442011-11-29 18:15:50 +0000219template <class _Rp, class _A1, class _A2>
220struct __weak_result_type<_Rp (_A1, _A2)>
221 : public binary_function<_A1, _A2, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000222{
223};
224
Howard Hinnant99968442011-11-29 18:15:50 +0000225template <class _Rp, class _A1, class _A2>
226struct __weak_result_type<_Rp (*)(_A1, _A2)>
227 : public binary_function<_A1, _A2, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000228{
229};
230
Howard Hinnant99968442011-11-29 18:15:50 +0000231template <class _Rp, class _A1, class _A2>
232struct __weak_result_type<_Rp (&)(_A1, _A2)>
233 : public binary_function<_A1, _A2, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000234{
235};
236
Howard Hinnant99968442011-11-29 18:15:50 +0000237template <class _Rp, class _Cp, class _A1>
238struct __weak_result_type<_Rp (_Cp::*)(_A1)>
239 : public binary_function<_Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000240{
241};
242
Howard Hinnant99968442011-11-29 18:15:50 +0000243template <class _Rp, class _Cp, class _A1>
244struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
245 : public binary_function<const _Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000246{
247};
248
Howard Hinnant99968442011-11-29 18:15:50 +0000249template <class _Rp, class _Cp, class _A1>
250struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
251 : public binary_function<volatile _Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000252{
253};
254
Howard Hinnant99968442011-11-29 18:15:50 +0000255template <class _Rp, class _Cp, class _A1>
256struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
257 : public binary_function<const volatile _Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000258{
259};
260
261// 3 or more arguments
262
Howard Hinnant99968442011-11-29 18:15:50 +0000263template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
264struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000265{
Howard Hinnant99968442011-11-29 18:15:50 +0000266 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000267};
268
Howard Hinnant99968442011-11-29 18:15:50 +0000269template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
270struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000271{
Howard Hinnant99968442011-11-29 18:15:50 +0000272 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000273};
274
Howard Hinnant99968442011-11-29 18:15:50 +0000275template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
276struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000277{
Howard Hinnant99968442011-11-29 18:15:50 +0000278 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000279};
280
Howard Hinnant99968442011-11-29 18:15:50 +0000281template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
282struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000283{
Howard Hinnant99968442011-11-29 18:15:50 +0000284 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000285};
286
Howard Hinnant99968442011-11-29 18:15:50 +0000287template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
288struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000289{
Howard Hinnant99968442011-11-29 18:15:50 +0000290 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000291};
292
Howard Hinnant99968442011-11-29 18:15:50 +0000293template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
294struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000295{
Howard Hinnant99968442011-11-29 18:15:50 +0000296 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000297};
298
Howard Hinnant99968442011-11-29 18:15:50 +0000299template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
300struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000301{
Howard Hinnant99968442011-11-29 18:15:50 +0000302 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000303};
304
305// __invoke
306
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000307// bullets 1 and 2
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000308
Howard Hinnantecc97422013-05-07 23:40:12 +0000309template <class _Fp, class _A0, class ..._Args,
310 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000311inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000312auto
Howard Hinnant99968442011-11-29 18:15:50 +0000313__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000314 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000315{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000316 return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000317}
318
Howard Hinnantecc97422013-05-07 23:40:12 +0000319template <class _Fp, class _A0, class ..._Args,
320 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000321inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000322auto
Howard Hinnant99968442011-11-29 18:15:50 +0000323__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000324 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000325{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000326 return ((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000327}
328
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000329// bullets 3 and 4
330
Howard Hinnantecc97422013-05-07 23:40:12 +0000331template <class _Fp, class _A0,
332 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000333inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000334auto
Howard Hinnant99968442011-11-29 18:15:50 +0000335__invoke(_Fp&& __f, _A0&& __a0)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000336 -> decltype(_VSTD::forward<_A0>(__a0).*__f)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000337{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000338 return _VSTD::forward<_A0>(__a0).*__f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000339}
340
Howard Hinnantecc97422013-05-07 23:40:12 +0000341template <class _Fp, class _A0,
342 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000343inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000344auto
Howard Hinnant99968442011-11-29 18:15:50 +0000345__invoke(_Fp&& __f, _A0&& __a0)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000346 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000347{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000348 return (*_VSTD::forward<_A0>(__a0)).*__f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000349}
350
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000351// bullet 5
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000352
Howard Hinnant99968442011-11-29 18:15:50 +0000353template <class _Fp, class ..._Args>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000354inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000355auto
Howard Hinnant99968442011-11-29 18:15:50 +0000356__invoke(_Fp&& __f, _Args&& ...__args)
357 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000358{
Howard Hinnant99968442011-11-29 18:15:50 +0000359 return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000360}
361
362template <class _Tp, class ..._Args>
363struct __invoke_return
364{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000365 typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000366};
367
368template <class _Tp>
Howard Hinnant83eade62013-03-06 23:30:19 +0000369class _LIBCPP_TYPE_VIS reference_wrapper
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000370 : public __weak_result_type<_Tp>
371{
372public:
373 // types
374 typedef _Tp type;
375private:
376 type* __f_;
377
378public:
379 // construct/copy/destroy
Arnold Schwaighofera709c822013-08-08 03:06:24 +0000380 _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT : __f_(&__f) {}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000381#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000382 private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
383#endif
384
385 // access
Howard Hinnant603d2c02011-05-28 17:59:48 +0000386 _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;}
387 _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000388
389 // invoke
390 template <class... _ArgTypes>
Howard Hinnant99acc502010-09-21 17:32:39 +0000391 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant57cff292011-05-19 15:05:04 +0000392 typename __invoke_of<type&, _ArgTypes...>::type
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000393 operator() (_ArgTypes&&... __args) const
394 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000395 return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000396 }
397};
398
399template <class _Tp> struct ____is_reference_wrapper : public false_type {};
400template <class _Tp> struct ____is_reference_wrapper<reference_wrapper<_Tp> > : public true_type {};
401template <class _Tp> struct __is_reference_wrapper
402 : public ____is_reference_wrapper<typename remove_cv<_Tp>::type> {};
403
404template <class _Tp>
405inline _LIBCPP_INLINE_VISIBILITY
406reference_wrapper<_Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000407ref(_Tp& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000408{
409 return reference_wrapper<_Tp>(__t);
410}
411
412template <class _Tp>
413inline _LIBCPP_INLINE_VISIBILITY
414reference_wrapper<_Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000415ref(reference_wrapper<_Tp> __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000416{
417 return ref(__t.get());
418}
419
420template <class _Tp>
421inline _LIBCPP_INLINE_VISIBILITY
422reference_wrapper<const _Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000423cref(const _Tp& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000424{
425 return reference_wrapper<const _Tp>(__t);
426}
427
428template <class _Tp>
429inline _LIBCPP_INLINE_VISIBILITY
430reference_wrapper<const _Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000431cref(reference_wrapper<_Tp> __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000432{
433 return cref(__t.get());
434}
435
Howard Hinnant73d21a42010-09-04 23:28:19 +0000436#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
437#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
438
Howard Hinnantec3773c2011-12-01 20:21:04 +0000439template <class _Tp> void ref(const _Tp&&) = delete;
440template <class _Tp> void cref(const _Tp&&) = delete;
Howard Hinnant73d21a42010-09-04 23:28:19 +0000441
442#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
443
Howard Hinnantec3773c2011-12-01 20:21:04 +0000444template <class _Tp> void ref(const _Tp&&);// = delete;
445template <class _Tp> void cref(const _Tp&&);// = delete;
Howard Hinnant73d21a42010-09-04 23:28:19 +0000446
447#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
448
449#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000450
451#endif // _LIBCPP_HAS_NO_VARIADICS
452
453_LIBCPP_END_NAMESPACE_STD
454
455#endif // _LIBCPP_FUNCTIONAL_BASE