blob: 5b0d7201d6f7f084d5950ef06fa97ea58099e067 [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
Howard Hinnant3fadda32012-02-21 21:02:58 +000053template <class _Tp>
Howard Hinnant83eade62013-03-06 23:30:19 +000054struct _LIBCPP_TYPE_VIS less : binary_function<_Tp, _Tp, bool>
Howard Hinnant3fadda32012-02-21 21:02:58 +000055{
56 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const
57 {return __x < __y;}
58};
59
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000060#ifdef _LIBCPP_HAS_NO_VARIADICS
61
62#include <__functional_base_03>
63
64#else // _LIBCPP_HAS_NO_VARIADICS
65
66// __weak_result_type
67
68template <class _Tp>
69struct __derives_from_unary_function
70{
71private:
Howard Hinnant9c0df142012-10-30 19:06:59 +000072 struct __two {char __lx; char __lxx;};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000073 static __two __test(...);
Howard Hinnant99968442011-11-29 18:15:50 +000074 template <class _Ap, class _Rp>
75 static unary_function<_Ap, _Rp>
76 __test(const volatile unary_function<_Ap, _Rp>*);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000077public:
78 static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
79 typedef decltype(__test((_Tp*)0)) type;
80};
81
82template <class _Tp>
83struct __derives_from_binary_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 _A1, class _A2, class _Rp>
89 static binary_function<_A1, _A2, _Rp>
90 __test(const volatile binary_function<_A1, _A2, _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, bool = __derives_from_unary_function<_Tp>::value>
97struct __maybe_derive_from_unary_function // bool is true
98 : public __derives_from_unary_function<_Tp>::type
99{
100};
101
102template <class _Tp>
103struct __maybe_derive_from_unary_function<_Tp, false>
104{
105};
106
107template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
108struct __maybe_derive_from_binary_function // bool is true
109 : public __derives_from_binary_function<_Tp>::type
110{
111};
112
113template <class _Tp>
114struct __maybe_derive_from_binary_function<_Tp, false>
115{
116};
117
118template <class _Tp, bool = __has_result_type<_Tp>::value>
119struct __weak_result_type_imp // bool is true
120 : public __maybe_derive_from_unary_function<_Tp>,
121 public __maybe_derive_from_binary_function<_Tp>
122{
123 typedef typename _Tp::result_type result_type;
124};
125
126template <class _Tp>
127struct __weak_result_type_imp<_Tp, false>
128 : public __maybe_derive_from_unary_function<_Tp>,
129 public __maybe_derive_from_binary_function<_Tp>
130{
131};
132
133template <class _Tp>
134struct __weak_result_type
135 : public __weak_result_type_imp<_Tp>
136{
137};
138
139// 0 argument case
140
Howard Hinnant99968442011-11-29 18:15:50 +0000141template <class _Rp>
142struct __weak_result_type<_Rp ()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000143{
Howard Hinnant99968442011-11-29 18:15:50 +0000144 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000145};
146
Howard Hinnant99968442011-11-29 18:15:50 +0000147template <class _Rp>
148struct __weak_result_type<_Rp (&)()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000149{
Howard Hinnant99968442011-11-29 18:15:50 +0000150 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000151};
152
Howard Hinnant99968442011-11-29 18:15:50 +0000153template <class _Rp>
154struct __weak_result_type<_Rp (*)()>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000155{
Howard Hinnant99968442011-11-29 18:15:50 +0000156 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000157};
158
159// 1 argument case
160
Howard Hinnant99968442011-11-29 18:15:50 +0000161template <class _Rp, class _A1>
162struct __weak_result_type<_Rp (_A1)>
163 : public unary_function<_A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000164{
165};
166
Howard Hinnant99968442011-11-29 18:15:50 +0000167template <class _Rp, class _A1>
168struct __weak_result_type<_Rp (&)(_A1)>
169 : public unary_function<_A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000170{
171};
172
Howard Hinnant99968442011-11-29 18:15:50 +0000173template <class _Rp, class _A1>
174struct __weak_result_type<_Rp (*)(_A1)>
175 : public unary_function<_A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000176{
177};
178
Howard Hinnant99968442011-11-29 18:15:50 +0000179template <class _Rp, class _Cp>
180struct __weak_result_type<_Rp (_Cp::*)()>
181 : public unary_function<_Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000182{
183};
184
Howard Hinnant99968442011-11-29 18:15:50 +0000185template <class _Rp, class _Cp>
186struct __weak_result_type<_Rp (_Cp::*)() const>
187 : public unary_function<const _Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000188{
189};
190
Howard Hinnant99968442011-11-29 18:15:50 +0000191template <class _Rp, class _Cp>
192struct __weak_result_type<_Rp (_Cp::*)() volatile>
193 : public unary_function<volatile _Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000194{
195};
196
Howard Hinnant99968442011-11-29 18:15:50 +0000197template <class _Rp, class _Cp>
198struct __weak_result_type<_Rp (_Cp::*)() const volatile>
199 : public unary_function<const volatile _Cp*, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000200{
201};
202
203// 2 argument case
204
Howard Hinnant99968442011-11-29 18:15:50 +0000205template <class _Rp, class _A1, class _A2>
206struct __weak_result_type<_Rp (_A1, _A2)>
207 : public binary_function<_A1, _A2, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000208{
209};
210
Howard Hinnant99968442011-11-29 18:15:50 +0000211template <class _Rp, class _A1, class _A2>
212struct __weak_result_type<_Rp (*)(_A1, _A2)>
213 : public binary_function<_A1, _A2, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000214{
215};
216
Howard Hinnant99968442011-11-29 18:15:50 +0000217template <class _Rp, class _A1, class _A2>
218struct __weak_result_type<_Rp (&)(_A1, _A2)>
219 : public binary_function<_A1, _A2, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000220{
221};
222
Howard Hinnant99968442011-11-29 18:15:50 +0000223template <class _Rp, class _Cp, class _A1>
224struct __weak_result_type<_Rp (_Cp::*)(_A1)>
225 : public binary_function<_Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000226{
227};
228
Howard Hinnant99968442011-11-29 18:15:50 +0000229template <class _Rp, class _Cp, class _A1>
230struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
231 : public binary_function<const _Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000232{
233};
234
Howard Hinnant99968442011-11-29 18:15:50 +0000235template <class _Rp, class _Cp, class _A1>
236struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
237 : public binary_function<volatile _Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000238{
239};
240
Howard Hinnant99968442011-11-29 18:15:50 +0000241template <class _Rp, class _Cp, class _A1>
242struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
243 : public binary_function<const volatile _Cp*, _A1, _Rp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000244{
245};
246
247// 3 or more arguments
248
Howard Hinnant99968442011-11-29 18:15:50 +0000249template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
250struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000251{
Howard Hinnant99968442011-11-29 18:15:50 +0000252 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000253};
254
Howard Hinnant99968442011-11-29 18:15:50 +0000255template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
256struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000257{
Howard Hinnant99968442011-11-29 18:15:50 +0000258 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000259};
260
Howard Hinnant99968442011-11-29 18:15:50 +0000261template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
262struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000263{
Howard Hinnant99968442011-11-29 18:15:50 +0000264 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000265};
266
Howard Hinnant99968442011-11-29 18:15:50 +0000267template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
268struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000269{
Howard Hinnant99968442011-11-29 18:15:50 +0000270 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000271};
272
Howard Hinnant99968442011-11-29 18:15:50 +0000273template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
274struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000275{
Howard Hinnant99968442011-11-29 18:15:50 +0000276 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000277};
278
Howard Hinnant99968442011-11-29 18:15:50 +0000279template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
280struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000281{
Howard Hinnant99968442011-11-29 18:15:50 +0000282 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000283};
284
Howard Hinnant99968442011-11-29 18:15:50 +0000285template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
286struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000287{
Howard Hinnant99968442011-11-29 18:15:50 +0000288 typedef _Rp result_type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000289};
290
291// __invoke
292
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000293// bullets 1 and 2
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000294
Howard Hinnantecc97422013-05-07 23:40:12 +0000295template <class _Fp, class _A0, class ..._Args,
296 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000297inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000298auto
Howard Hinnant99968442011-11-29 18:15:50 +0000299__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000300 -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000301{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000302 return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000303}
304
Howard Hinnantecc97422013-05-07 23:40:12 +0000305template <class _Fp, class _A0, class ..._Args,
306 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000307inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000308auto
Howard Hinnant99968442011-11-29 18:15:50 +0000309__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000310 -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000311{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000312 return ((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000313}
314
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000315// bullets 3 and 4
316
Howard Hinnantecc97422013-05-07 23:40:12 +0000317template <class _Fp, class _A0,
318 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000319inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000320auto
Howard Hinnant99968442011-11-29 18:15:50 +0000321__invoke(_Fp&& __f, _A0&& __a0)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000322 -> decltype(_VSTD::forward<_A0>(__a0).*__f)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000323{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000324 return _VSTD::forward<_A0>(__a0).*__f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000325}
326
Howard Hinnantecc97422013-05-07 23:40:12 +0000327template <class _Fp, class _A0,
328 class>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000329inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000330auto
Howard Hinnant99968442011-11-29 18:15:50 +0000331__invoke(_Fp&& __f, _A0&& __a0)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000332 -> decltype((*_VSTD::forward<_A0>(__a0)).*__f)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000333{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000334 return (*_VSTD::forward<_A0>(__a0)).*__f;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000335}
336
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000337// bullet 5
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000338
Howard Hinnant99968442011-11-29 18:15:50 +0000339template <class _Fp, class ..._Args>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000340inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd89e4b2011-05-20 22:02:53 +0000341auto
Howard Hinnant99968442011-11-29 18:15:50 +0000342__invoke(_Fp&& __f, _Args&& ...__args)
343 -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000344{
Howard Hinnant99968442011-11-29 18:15:50 +0000345 return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000346}
347
348template <class _Tp, class ..._Args>
349struct __invoke_return
350{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000351 typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000352};
353
354template <class _Tp>
Howard Hinnant83eade62013-03-06 23:30:19 +0000355class _LIBCPP_TYPE_VIS reference_wrapper
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000356 : public __weak_result_type<_Tp>
357{
358public:
359 // types
360 typedef _Tp type;
361private:
362 type* __f_;
363
364public:
365 // construct/copy/destroy
Howard Hinnant603d2c02011-05-28 17:59:48 +0000366 _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT : __f_(&__f) {}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000367#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000368 private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
369#endif
370
371 // access
Howard Hinnant603d2c02011-05-28 17:59:48 +0000372 _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;}
373 _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000374
375 // invoke
376 template <class... _ArgTypes>
Howard Hinnant99acc502010-09-21 17:32:39 +0000377 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant57cff292011-05-19 15:05:04 +0000378 typename __invoke_of<type&, _ArgTypes...>::type
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000379 operator() (_ArgTypes&&... __args) const
380 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000381 return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000382 }
383};
384
385template <class _Tp> struct ____is_reference_wrapper : public false_type {};
386template <class _Tp> struct ____is_reference_wrapper<reference_wrapper<_Tp> > : public true_type {};
387template <class _Tp> struct __is_reference_wrapper
388 : public ____is_reference_wrapper<typename remove_cv<_Tp>::type> {};
389
390template <class _Tp>
391inline _LIBCPP_INLINE_VISIBILITY
392reference_wrapper<_Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000393ref(_Tp& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000394{
395 return reference_wrapper<_Tp>(__t);
396}
397
398template <class _Tp>
399inline _LIBCPP_INLINE_VISIBILITY
400reference_wrapper<_Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000401ref(reference_wrapper<_Tp> __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000402{
403 return ref(__t.get());
404}
405
406template <class _Tp>
407inline _LIBCPP_INLINE_VISIBILITY
408reference_wrapper<const _Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000409cref(const _Tp& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000410{
411 return reference_wrapper<const _Tp>(__t);
412}
413
414template <class _Tp>
415inline _LIBCPP_INLINE_VISIBILITY
416reference_wrapper<const _Tp>
Howard Hinnant603d2c02011-05-28 17:59:48 +0000417cref(reference_wrapper<_Tp> __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000418{
419 return cref(__t.get());
420}
421
Howard Hinnant73d21a42010-09-04 23:28:19 +0000422#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
423#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
424
Howard Hinnantec3773c2011-12-01 20:21:04 +0000425template <class _Tp> void ref(const _Tp&&) = delete;
426template <class _Tp> void cref(const _Tp&&) = delete;
Howard Hinnant73d21a42010-09-04 23:28:19 +0000427
428#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
429
Howard Hinnantec3773c2011-12-01 20:21:04 +0000430template <class _Tp> void ref(const _Tp&&);// = delete;
431template <class _Tp> void cref(const _Tp&&);// = delete;
Howard Hinnant73d21a42010-09-04 23:28:19 +0000432
433#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
434
435#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000436
437#endif // _LIBCPP_HAS_NO_VARIADICS
438
439_LIBCPP_END_NAMESPACE_STD
440
441#endif // _LIBCPP_FUNCTIONAL_BASE