2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_FUNCTIONAL_03
11 #define _LIBCPP_FUNCTIONAL_03
13 // manual variadic expansion for <functional>
15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16 #pragma GCC system_header
19 namespace __function {
21 template<class _Fp> class __base;
26 __base(const __base&);
27 __base& operator=(const __base&);
31 virtual __base* __clone() const = 0;
32 virtual void __clone(__base*) const = 0;
33 virtual void destroy() = 0;
34 virtual void destroy_deallocate() = 0;
35 virtual _Rp operator()() = 0;
36 #ifndef _LIBCPP_NO_RTTI
37 virtual const void* target(const type_info&) const = 0;
38 virtual const std::type_info& target_type() const = 0;
39 #endif // _LIBCPP_NO_RTTI
42 template<class _Rp, class _A0>
43 class __base<_Rp(_A0)>
45 __base(const __base&);
46 __base& operator=(const __base&);
50 virtual __base* __clone() const = 0;
51 virtual void __clone(__base*) const = 0;
52 virtual void destroy() = 0;
53 virtual void destroy_deallocate() = 0;
54 virtual _Rp operator()(_A0) = 0;
55 #ifndef _LIBCPP_NO_RTTI
56 virtual const void* target(const type_info&) const = 0;
57 virtual const std::type_info& target_type() const = 0;
58 #endif // _LIBCPP_NO_RTTI
61 template<class _Rp, class _A0, class _A1>
62 class __base<_Rp(_A0, _A1)>
64 __base(const __base&);
65 __base& operator=(const __base&);
69 virtual __base* __clone() const = 0;
70 virtual void __clone(__base*) const = 0;
71 virtual void destroy() = 0;
72 virtual void destroy_deallocate() = 0;
73 virtual _Rp operator()(_A0, _A1) = 0;
74 #ifndef _LIBCPP_NO_RTTI
75 virtual const void* target(const type_info&) const = 0;
76 virtual const std::type_info& target_type() const = 0;
77 #endif // _LIBCPP_NO_RTTI
80 template<class _Rp, class _A0, class _A1, class _A2>
81 class __base<_Rp(_A0, _A1, _A2)>
83 __base(const __base&);
84 __base& operator=(const __base&);
88 virtual __base* __clone() const = 0;
89 virtual void __clone(__base*) const = 0;
90 virtual void destroy() = 0;
91 virtual void destroy_deallocate() = 0;
92 virtual _Rp operator()(_A0, _A1, _A2) = 0;
93 #ifndef _LIBCPP_NO_RTTI
94 virtual const void* target(const type_info&) const = 0;
95 virtual const std::type_info& target_type() const = 0;
96 #endif // _LIBCPP_NO_RTTI
99 template<class _FD, class _Alloc, class _FB> class __func;
101 template<class _Fp, class _Alloc, class _Rp>
102 class __func<_Fp, _Alloc, _Rp()>
103 : public __base<_Rp()>
105 __compressed_pair<_Fp, _Alloc> __f_;
107 explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
108 explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
109 virtual __base<_Rp()>* __clone() const;
110 virtual void __clone(__base<_Rp()>*) const;
111 virtual void destroy();
112 virtual void destroy_deallocate();
113 virtual _Rp operator()();
114 #ifndef _LIBCPP_NO_RTTI
115 virtual const void* target(const type_info&) const;
116 virtual const std::type_info& target_type() const;
117 #endif // _LIBCPP_NO_RTTI
120 template<class _Fp, class _Alloc, class _Rp>
122 __func<_Fp, _Alloc, _Rp()>::__clone() const
124 typedef allocator_traits<_Alloc> __alloc_traits;
125 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
126 _Ap __a(__f_.second());
127 typedef __allocator_destructor<_Ap> _Dp;
128 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
129 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
130 return __hold.release();
133 template<class _Fp, class _Alloc, class _Rp>
135 __func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
137 ::new (__p) __func(__f_.first(), __f_.second());
140 template<class _Fp, class _Alloc, class _Rp>
142 __func<_Fp, _Alloc, _Rp()>::destroy()
144 __f_.~__compressed_pair<_Fp, _Alloc>();
147 template<class _Fp, class _Alloc, class _Rp>
149 __func<_Fp, _Alloc, _Rp()>::destroy_deallocate()
151 typedef allocator_traits<_Alloc> __alloc_traits;
152 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
153 _Ap __a(__f_.second());
154 __f_.~__compressed_pair<_Fp, _Alloc>();
155 __a.deallocate(this, 1);
158 template<class _Fp, class _Alloc, class _Rp>
160 __func<_Fp, _Alloc, _Rp()>::operator()()
162 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
163 return _Invoker::__call(__f_.first());
166 #ifndef _LIBCPP_NO_RTTI
168 template<class _Fp, class _Alloc, class _Rp>
170 __func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const
172 if (__ti == typeid(_Fp))
173 return &__f_.first();
174 return (const void*)0;
177 template<class _Fp, class _Alloc, class _Rp>
178 const std::type_info&
179 __func<_Fp, _Alloc, _Rp()>::target_type() const
184 #endif // _LIBCPP_NO_RTTI
186 template<class _Fp, class _Alloc, class _Rp, class _A0>
187 class __func<_Fp, _Alloc, _Rp(_A0)>
188 : public __base<_Rp(_A0)>
190 __compressed_pair<_Fp, _Alloc> __f_;
192 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
193 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
194 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
195 virtual __base<_Rp(_A0)>* __clone() const;
196 virtual void __clone(__base<_Rp(_A0)>*) const;
197 virtual void destroy();
198 virtual void destroy_deallocate();
199 virtual _Rp operator()(_A0);
200 #ifndef _LIBCPP_NO_RTTI
201 virtual const void* target(const type_info&) const;
202 virtual const std::type_info& target_type() const;
203 #endif // _LIBCPP_NO_RTTI
206 template<class _Fp, class _Alloc, class _Rp, class _A0>
208 __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
210 typedef allocator_traits<_Alloc> __alloc_traits;
211 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
212 _Ap __a(__f_.second());
213 typedef __allocator_destructor<_Ap> _Dp;
214 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
215 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
216 return __hold.release();
219 template<class _Fp, class _Alloc, class _Rp, class _A0>
221 __func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
223 ::new (__p) __func(__f_.first(), __f_.second());
226 template<class _Fp, class _Alloc, class _Rp, class _A0>
228 __func<_Fp, _Alloc, _Rp(_A0)>::destroy()
230 __f_.~__compressed_pair<_Fp, _Alloc>();
233 template<class _Fp, class _Alloc, class _Rp, class _A0>
235 __func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate()
237 typedef allocator_traits<_Alloc> __alloc_traits;
238 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
239 _Ap __a(__f_.second());
240 __f_.~__compressed_pair<_Fp, _Alloc>();
241 __a.deallocate(this, 1);
244 template<class _Fp, class _Alloc, class _Rp, class _A0>
246 __func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0)
248 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
249 return _Invoker::__call(__f_.first(), __a0);
252 #ifndef _LIBCPP_NO_RTTI
254 template<class _Fp, class _Alloc, class _Rp, class _A0>
256 __func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const
258 if (__ti == typeid(_Fp))
259 return &__f_.first();
260 return (const void*)0;
263 template<class _Fp, class _Alloc, class _Rp, class _A0>
264 const std::type_info&
265 __func<_Fp, _Alloc, _Rp(_A0)>::target_type() const
270 #endif // _LIBCPP_NO_RTTI
272 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
273 class __func<_Fp, _Alloc, _Rp(_A0, _A1)>
274 : public __base<_Rp(_A0, _A1)>
276 __compressed_pair<_Fp, _Alloc> __f_;
278 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
279 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
280 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
281 virtual __base<_Rp(_A0, _A1)>* __clone() const;
282 virtual void __clone(__base<_Rp(_A0, _A1)>*) const;
283 virtual void destroy();
284 virtual void destroy_deallocate();
285 virtual _Rp operator()(_A0, _A1);
286 #ifndef _LIBCPP_NO_RTTI
287 virtual const void* target(const type_info&) const;
288 virtual const std::type_info& target_type() const;
289 #endif // _LIBCPP_NO_RTTI
292 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
293 __base<_Rp(_A0, _A1)>*
294 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
296 typedef allocator_traits<_Alloc> __alloc_traits;
297 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
298 _Ap __a(__f_.second());
299 typedef __allocator_destructor<_Ap> _Dp;
300 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
301 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
302 return __hold.release();
305 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
307 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
309 ::new (__p) __func(__f_.first(), __f_.second());
312 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
314 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy()
316 __f_.~__compressed_pair<_Fp, _Alloc>();
319 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
321 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate()
323 typedef allocator_traits<_Alloc> __alloc_traits;
324 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
325 _Ap __a(__f_.second());
326 __f_.~__compressed_pair<_Fp, _Alloc>();
327 __a.deallocate(this, 1);
330 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
332 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1)
334 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
335 return _Invoker::__call(__f_.first(), __a0, __a1);
338 #ifndef _LIBCPP_NO_RTTI
340 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
342 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const
344 if (__ti == typeid(_Fp))
345 return &__f_.first();
346 return (const void*)0;
349 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
350 const std::type_info&
351 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const
356 #endif // _LIBCPP_NO_RTTI
358 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
359 class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>
360 : public __base<_Rp(_A0, _A1, _A2)>
362 __compressed_pair<_Fp, _Alloc> __f_;
364 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
365 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
366 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
367 virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const;
368 virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const;
369 virtual void destroy();
370 virtual void destroy_deallocate();
371 virtual _Rp operator()(_A0, _A1, _A2);
372 #ifndef _LIBCPP_NO_RTTI
373 virtual const void* target(const type_info&) const;
374 virtual const std::type_info& target_type() const;
375 #endif // _LIBCPP_NO_RTTI
378 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
379 __base<_Rp(_A0, _A1, _A2)>*
380 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
382 typedef allocator_traits<_Alloc> __alloc_traits;
383 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
384 _Ap __a(__f_.second());
385 typedef __allocator_destructor<_Ap> _Dp;
386 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
387 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
388 return __hold.release();
391 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
393 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
395 ::new (__p) __func(__f_.first(), __f_.second());
398 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
400 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy()
402 __f_.~__compressed_pair<_Fp, _Alloc>();
405 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
407 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate()
409 typedef allocator_traits<_Alloc> __alloc_traits;
410 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
411 _Ap __a(__f_.second());
412 __f_.~__compressed_pair<_Fp, _Alloc>();
413 __a.deallocate(this, 1);
416 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
418 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2)
420 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
421 return _Invoker::__call(__f_.first(), __a0, __a1, __a2);
424 #ifndef _LIBCPP_NO_RTTI
426 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
428 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const
430 if (__ti == typeid(_Fp))
431 return &__f_.first();
432 return (const void*)0;
435 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
436 const std::type_info&
437 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const
442 #endif // _LIBCPP_NO_RTTI
447 class _LIBCPP_TEMPLATE_VIS function<_Rp()>
449 typedef __function::__base<_Rp()> __base;
450 aligned_storage<3*sizeof(void*)>::type __buf_;
454 typedef _Rp result_type;
456 // 20.7.16.2.1, construct/copy/destroy:
457 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
458 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
459 function(const function&);
462 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
464 template<class _Alloc>
465 _LIBCPP_INLINE_VISIBILITY
466 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
467 template<class _Alloc>
468 _LIBCPP_INLINE_VISIBILITY
469 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
470 template<class _Alloc>
471 function(allocator_arg_t, const _Alloc&, const function&);
472 template<class _Fp, class _Alloc>
473 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
474 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
476 function& operator=(const function&);
477 function& operator=(nullptr_t);
481 !is_integral<_Fp>::value,
488 // 20.7.16.2.2, function modifiers:
489 void swap(function&);
490 template<class _Fp, class _Alloc>
491 _LIBCPP_INLINE_VISIBILITY
492 void assign(_Fp __f, const _Alloc& __a)
493 {function(allocator_arg, __a, __f).swap(*this);}
495 // 20.7.16.2.3, function capacity:
496 _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
499 // deleted overloads close possible hole in the type system
501 bool operator==(const function<_R2()>&) const;// = delete;
503 bool operator!=(const function<_R2()>&) const;// = delete;
505 // 20.7.16.2.4, function invocation:
506 _Rp operator()() const;
508 #ifndef _LIBCPP_NO_RTTI
509 // 20.7.16.2.5, function target access:
510 const std::type_info& target_type() const;
511 template <typename _Tp> _Tp* target();
512 template <typename _Tp> const _Tp* target() const;
513 #endif // _LIBCPP_NO_RTTI
517 function<_Rp()>::function(const function& __f)
521 else if (__f.__f_ == (const __base*)&__f.__buf_)
523 __f_ = (__base*)&__buf_;
524 __f.__f_->__clone(__f_);
527 __f_ = __f.__f_->__clone();
531 template<class _Alloc>
532 function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f)
536 else if (__f.__f_ == (const __base*)&__f.__buf_)
538 __f_ = (__base*)&__buf_;
539 __f.__f_->__clone(__f_);
542 __f_ = __f.__f_->__clone();
547 function<_Rp()>::function(_Fp __f,
548 typename enable_if<!is_integral<_Fp>::value>::type*)
551 if (__function::__not_null(__f))
553 typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF;
554 if (sizeof(_FF) <= sizeof(__buf_))
556 __f_ = (__base*)&__buf_;
557 ::new (__f_) _FF(__f);
561 typedef allocator<_FF> _Ap;
563 typedef __allocator_destructor<_Ap> _Dp;
564 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
565 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
566 __f_ = __hold.release();
572 template <class _Fp, class _Alloc>
573 function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
574 typename enable_if<!is_integral<_Fp>::value>::type*)
577 typedef allocator_traits<_Alloc> __alloc_traits;
578 if (__function::__not_null(__f))
580 typedef __function::__func<_Fp, _Alloc, _Rp()> _FF;
581 if (sizeof(_FF) <= sizeof(__buf_))
583 __f_ = (__base*)&__buf_;
584 ::new (__f_) _FF(__f, __a0);
588 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
590 typedef __allocator_destructor<_Ap> _Dp;
591 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
592 ::new (__hold.get()) _FF(__f, _Alloc(__a));
593 __f_ = __hold.release();
600 function<_Rp()>::operator=(const function& __f)
603 function(__f).swap(*this);
611 function<_Rp()>::operator=(nullptr_t)
615 if (__t == (__base*)&__buf_)
618 __t->destroy_deallocate();
626 !is_integral<_Fp>::value,
629 function<_Rp()>::operator=(_Fp __f)
631 function(_VSTD::move(__f)).swap(*this);
636 function<_Rp()>::~function()
638 if (__f_ == (__base*)&__buf_)
641 __f_->destroy_deallocate();
646 function<_Rp()>::swap(function& __f)
648 if (_VSTD::addressof(__f) == this)
650 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
652 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
653 __base* __t = (__base*)&__tempbuf;
657 __f.__f_->__clone((__base*)&__buf_);
660 __f_ = (__base*)&__buf_;
661 __t->__clone((__base*)&__f.__buf_);
663 __f.__f_ = (__base*)&__f.__buf_;
665 else if (__f_ == (__base*)&__buf_)
667 __f_->__clone((__base*)&__f.__buf_);
670 __f.__f_ = (__base*)&__f.__buf_;
672 else if (__f.__f_ == (__base*)&__f.__buf_)
674 __f.__f_->__clone((__base*)&__buf_);
677 __f_ = (__base*)&__buf_;
680 _VSTD::swap(__f_, __f.__f_);
685 function<_Rp()>::operator()() const
688 __throw_bad_function_call();
692 #ifndef _LIBCPP_NO_RTTI
695 const std::type_info&
696 function<_Rp()>::target_type() const
700 return __f_->target_type();
704 template <typename _Tp>
706 function<_Rp()>::target()
710 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
714 template <typename _Tp>
716 function<_Rp()>::target() const
719 return (const _Tp*)0;
720 return (const _Tp*)__f_->target(typeid(_Tp));
723 #endif // _LIBCPP_NO_RTTI
725 template<class _Rp, class _A0>
726 class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)>
727 : public unary_function<_A0, _Rp>
729 typedef __function::__base<_Rp(_A0)> __base;
730 aligned_storage<3*sizeof(void*)>::type __buf_;
734 typedef _Rp result_type;
736 // 20.7.16.2.1, construct/copy/destroy:
737 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
738 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
739 function(const function&);
742 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
744 template<class _Alloc>
745 _LIBCPP_INLINE_VISIBILITY
746 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
747 template<class _Alloc>
748 _LIBCPP_INLINE_VISIBILITY
749 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
750 template<class _Alloc>
751 function(allocator_arg_t, const _Alloc&, const function&);
752 template<class _Fp, class _Alloc>
753 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
754 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
756 function& operator=(const function&);
757 function& operator=(nullptr_t);
761 !is_integral<_Fp>::value,
768 // 20.7.16.2.2, function modifiers:
769 void swap(function&);
770 template<class _Fp, class _Alloc>
771 _LIBCPP_INLINE_VISIBILITY
772 void assign(_Fp __f, const _Alloc& __a)
773 {function(allocator_arg, __a, __f).swap(*this);}
775 // 20.7.16.2.3, function capacity:
776 _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
779 // deleted overloads close possible hole in the type system
780 template<class _R2, class _B0>
781 bool operator==(const function<_R2(_B0)>&) const;// = delete;
782 template<class _R2, class _B0>
783 bool operator!=(const function<_R2(_B0)>&) const;// = delete;
785 // 20.7.16.2.4, function invocation:
786 _Rp operator()(_A0) const;
788 #ifndef _LIBCPP_NO_RTTI
789 // 20.7.16.2.5, function target access:
790 const std::type_info& target_type() const;
791 template <typename _Tp> _Tp* target();
792 template <typename _Tp> const _Tp* target() const;
793 #endif // _LIBCPP_NO_RTTI
796 template<class _Rp, class _A0>
797 function<_Rp(_A0)>::function(const function& __f)
801 else if (__f.__f_ == (const __base*)&__f.__buf_)
803 __f_ = (__base*)&__buf_;
804 __f.__f_->__clone(__f_);
807 __f_ = __f.__f_->__clone();
810 template<class _Rp, class _A0>
811 template<class _Alloc>
812 function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f)
816 else if (__f.__f_ == (const __base*)&__f.__buf_)
818 __f_ = (__base*)&__buf_;
819 __f.__f_->__clone(__f_);
822 __f_ = __f.__f_->__clone();
825 template<class _Rp, class _A0>
827 function<_Rp(_A0)>::function(_Fp __f,
828 typename enable_if<!is_integral<_Fp>::value>::type*)
831 if (__function::__not_null(__f))
833 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF;
834 if (sizeof(_FF) <= sizeof(__buf_))
836 __f_ = (__base*)&__buf_;
837 ::new (__f_) _FF(__f);
841 typedef allocator<_FF> _Ap;
843 typedef __allocator_destructor<_Ap> _Dp;
844 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
845 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
846 __f_ = __hold.release();
851 template<class _Rp, class _A0>
852 template <class _Fp, class _Alloc>
853 function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
854 typename enable_if<!is_integral<_Fp>::value>::type*)
857 typedef allocator_traits<_Alloc> __alloc_traits;
858 if (__function::__not_null(__f))
860 typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF;
861 if (sizeof(_FF) <= sizeof(__buf_))
863 __f_ = (__base*)&__buf_;
864 ::new (__f_) _FF(__f, __a0);
868 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
870 typedef __allocator_destructor<_Ap> _Dp;
871 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
872 ::new (__hold.get()) _FF(__f, _Alloc(__a));
873 __f_ = __hold.release();
878 template<class _Rp, class _A0>
880 function<_Rp(_A0)>::operator=(const function& __f)
883 function(__f).swap(*this);
889 template<class _Rp, class _A0>
891 function<_Rp(_A0)>::operator=(nullptr_t)
895 if (__t == (__base*)&__buf_)
898 __t->destroy_deallocate();
902 template<class _Rp, class _A0>
906 !is_integral<_Fp>::value,
909 function<_Rp(_A0)>::operator=(_Fp __f)
911 function(_VSTD::move(__f)).swap(*this);
915 template<class _Rp, class _A0>
916 function<_Rp(_A0)>::~function()
918 if (__f_ == (__base*)&__buf_)
921 __f_->destroy_deallocate();
924 template<class _Rp, class _A0>
926 function<_Rp(_A0)>::swap(function& __f)
928 if (_VSTD::addressof(__f) == this)
930 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
932 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
933 __base* __t = (__base*)&__tempbuf;
937 __f.__f_->__clone((__base*)&__buf_);
940 __f_ = (__base*)&__buf_;
941 __t->__clone((__base*)&__f.__buf_);
943 __f.__f_ = (__base*)&__f.__buf_;
945 else if (__f_ == (__base*)&__buf_)
947 __f_->__clone((__base*)&__f.__buf_);
950 __f.__f_ = (__base*)&__f.__buf_;
952 else if (__f.__f_ == (__base*)&__f.__buf_)
954 __f.__f_->__clone((__base*)&__buf_);
957 __f_ = (__base*)&__buf_;
960 _VSTD::swap(__f_, __f.__f_);
963 template<class _Rp, class _A0>
965 function<_Rp(_A0)>::operator()(_A0 __a0) const
968 __throw_bad_function_call();
969 return (*__f_)(__a0);
972 #ifndef _LIBCPP_NO_RTTI
974 template<class _Rp, class _A0>
975 const std::type_info&
976 function<_Rp(_A0)>::target_type() const
980 return __f_->target_type();
983 template<class _Rp, class _A0>
984 template <typename _Tp>
986 function<_Rp(_A0)>::target()
990 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
993 template<class _Rp, class _A0>
994 template <typename _Tp>
996 function<_Rp(_A0)>::target() const
999 return (const _Tp*)0;
1000 return (const _Tp*)__f_->target(typeid(_Tp));
1003 #endif // _LIBCPP_NO_RTTI
1005 template<class _Rp, class _A0, class _A1>
1006 class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)>
1007 : public binary_function<_A0, _A1, _Rp>
1009 typedef __function::__base<_Rp(_A0, _A1)> __base;
1010 aligned_storage<3*sizeof(void*)>::type __buf_;
1014 typedef _Rp result_type;
1016 // 20.7.16.2.1, construct/copy/destroy:
1017 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
1018 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
1019 function(const function&);
1022 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1024 template<class _Alloc>
1025 _LIBCPP_INLINE_VISIBILITY
1026 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
1027 template<class _Alloc>
1028 _LIBCPP_INLINE_VISIBILITY
1029 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
1030 template<class _Alloc>
1031 function(allocator_arg_t, const _Alloc&, const function&);
1032 template<class _Fp, class _Alloc>
1033 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1034 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1036 function& operator=(const function&);
1037 function& operator=(nullptr_t);
1041 !is_integral<_Fp>::value,
1048 // 20.7.16.2.2, function modifiers:
1049 void swap(function&);
1050 template<class _Fp, class _Alloc>
1051 _LIBCPP_INLINE_VISIBILITY
1052 void assign(_Fp __f, const _Alloc& __a)
1053 {function(allocator_arg, __a, __f).swap(*this);}
1055 // 20.7.16.2.3, function capacity:
1056 operator bool() const {return __f_;}
1059 // deleted overloads close possible hole in the type system
1060 template<class _R2, class _B0, class _B1>
1061 bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete;
1062 template<class _R2, class _B0, class _B1>
1063 bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete;
1065 // 20.7.16.2.4, function invocation:
1066 _Rp operator()(_A0, _A1) const;
1068 #ifndef _LIBCPP_NO_RTTI
1069 // 20.7.16.2.5, function target access:
1070 const std::type_info& target_type() const;
1071 template <typename _Tp> _Tp* target();
1072 template <typename _Tp> const _Tp* target() const;
1073 #endif // _LIBCPP_NO_RTTI
1076 template<class _Rp, class _A0, class _A1>
1077 function<_Rp(_A0, _A1)>::function(const function& __f)
1081 else if (__f.__f_ == (const __base*)&__f.__buf_)
1083 __f_ = (__base*)&__buf_;
1084 __f.__f_->__clone(__f_);
1087 __f_ = __f.__f_->__clone();
1090 template<class _Rp, class _A0, class _A1>
1091 template<class _Alloc>
1092 function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f)
1096 else if (__f.__f_ == (const __base*)&__f.__buf_)
1098 __f_ = (__base*)&__buf_;
1099 __f.__f_->__clone(__f_);
1102 __f_ = __f.__f_->__clone();
1105 template<class _Rp, class _A0, class _A1>
1106 template <class _Fp>
1107 function<_Rp(_A0, _A1)>::function(_Fp __f,
1108 typename enable_if<!is_integral<_Fp>::value>::type*)
1111 if (__function::__not_null(__f))
1113 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF;
1114 if (sizeof(_FF) <= sizeof(__buf_))
1116 __f_ = (__base*)&__buf_;
1117 ::new (__f_) _FF(__f);
1121 typedef allocator<_FF> _Ap;
1123 typedef __allocator_destructor<_Ap> _Dp;
1124 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1125 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
1126 __f_ = __hold.release();
1131 template<class _Rp, class _A0, class _A1>
1132 template <class _Fp, class _Alloc>
1133 function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1134 typename enable_if<!is_integral<_Fp>::value>::type*)
1137 typedef allocator_traits<_Alloc> __alloc_traits;
1138 if (__function::__not_null(__f))
1140 typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF;
1141 if (sizeof(_FF) <= sizeof(__buf_))
1143 __f_ = (__base*)&__buf_;
1144 ::new (__f_) _FF(__f, __a0);
1148 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1150 typedef __allocator_destructor<_Ap> _Dp;
1151 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1152 ::new (__hold.get()) _FF(__f, _Alloc(__a));
1153 __f_ = __hold.release();
1158 template<class _Rp, class _A0, class _A1>
1159 function<_Rp(_A0, _A1)>&
1160 function<_Rp(_A0, _A1)>::operator=(const function& __f)
1163 function(__f).swap(*this);
1169 template<class _Rp, class _A0, class _A1>
1170 function<_Rp(_A0, _A1)>&
1171 function<_Rp(_A0, _A1)>::operator=(nullptr_t)
1175 if (__t == (__base*)&__buf_)
1178 __t->destroy_deallocate();
1182 template<class _Rp, class _A0, class _A1>
1183 template <class _Fp>
1186 !is_integral<_Fp>::value,
1187 function<_Rp(_A0, _A1)>&
1189 function<_Rp(_A0, _A1)>::operator=(_Fp __f)
1191 function(_VSTD::move(__f)).swap(*this);
1195 template<class _Rp, class _A0, class _A1>
1196 function<_Rp(_A0, _A1)>::~function()
1198 if (__f_ == (__base*)&__buf_)
1201 __f_->destroy_deallocate();
1204 template<class _Rp, class _A0, class _A1>
1206 function<_Rp(_A0, _A1)>::swap(function& __f)
1208 if (_VSTD::addressof(__f) == this)
1210 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1212 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1213 __base* __t = (__base*)&__tempbuf;
1217 __f.__f_->__clone((__base*)&__buf_);
1218 __f.__f_->destroy();
1220 __f_ = (__base*)&__buf_;
1221 __t->__clone((__base*)&__f.__buf_);
1223 __f.__f_ = (__base*)&__f.__buf_;
1225 else if (__f_ == (__base*)&__buf_)
1227 __f_->__clone((__base*)&__f.__buf_);
1230 __f.__f_ = (__base*)&__f.__buf_;
1232 else if (__f.__f_ == (__base*)&__f.__buf_)
1234 __f.__f_->__clone((__base*)&__buf_);
1235 __f.__f_->destroy();
1237 __f_ = (__base*)&__buf_;
1240 _VSTD::swap(__f_, __f.__f_);
1243 template<class _Rp, class _A0, class _A1>
1245 function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
1248 __throw_bad_function_call();
1249 return (*__f_)(__a0, __a1);
1252 #ifndef _LIBCPP_NO_RTTI
1254 template<class _Rp, class _A0, class _A1>
1255 const std::type_info&
1256 function<_Rp(_A0, _A1)>::target_type() const
1259 return typeid(void);
1260 return __f_->target_type();
1263 template<class _Rp, class _A0, class _A1>
1264 template <typename _Tp>
1266 function<_Rp(_A0, _A1)>::target()
1270 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
1273 template<class _Rp, class _A0, class _A1>
1274 template <typename _Tp>
1276 function<_Rp(_A0, _A1)>::target() const
1279 return (const _Tp*)0;
1280 return (const _Tp*)__f_->target(typeid(_Tp));
1283 #endif // _LIBCPP_NO_RTTI
1285 template<class _Rp, class _A0, class _A1, class _A2>
1286 class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)>
1288 typedef __function::__base<_Rp(_A0, _A1, _A2)> __base;
1289 aligned_storage<3*sizeof(void*)>::type __buf_;
1293 typedef _Rp result_type;
1295 // 20.7.16.2.1, construct/copy/destroy:
1296 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
1297 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
1298 function(const function&);
1301 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1303 template<class _Alloc>
1304 _LIBCPP_INLINE_VISIBILITY
1305 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
1306 template<class _Alloc>
1307 _LIBCPP_INLINE_VISIBILITY
1308 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
1309 template<class _Alloc>
1310 function(allocator_arg_t, const _Alloc&, const function&);
1311 template<class _Fp, class _Alloc>
1312 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1313 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1315 function& operator=(const function&);
1316 function& operator=(nullptr_t);
1320 !is_integral<_Fp>::value,
1327 // 20.7.16.2.2, function modifiers:
1328 void swap(function&);
1329 template<class _Fp, class _Alloc>
1330 _LIBCPP_INLINE_VISIBILITY
1331 void assign(_Fp __f, const _Alloc& __a)
1332 {function(allocator_arg, __a, __f).swap(*this);}
1334 // 20.7.16.2.3, function capacity:
1335 _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
1338 // deleted overloads close possible hole in the type system
1339 template<class _R2, class _B0, class _B1, class _B2>
1340 bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete;
1341 template<class _R2, class _B0, class _B1, class _B2>
1342 bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete;
1344 // 20.7.16.2.4, function invocation:
1345 _Rp operator()(_A0, _A1, _A2) const;
1347 #ifndef _LIBCPP_NO_RTTI
1348 // 20.7.16.2.5, function target access:
1349 const std::type_info& target_type() const;
1350 template <typename _Tp> _Tp* target();
1351 template <typename _Tp> const _Tp* target() const;
1352 #endif // _LIBCPP_NO_RTTI
1355 template<class _Rp, class _A0, class _A1, class _A2>
1356 function<_Rp(_A0, _A1, _A2)>::function(const function& __f)
1360 else if (__f.__f_ == (const __base*)&__f.__buf_)
1362 __f_ = (__base*)&__buf_;
1363 __f.__f_->__clone(__f_);
1366 __f_ = __f.__f_->__clone();
1369 template<class _Rp, class _A0, class _A1, class _A2>
1370 template<class _Alloc>
1371 function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&,
1372 const function& __f)
1376 else if (__f.__f_ == (const __base*)&__f.__buf_)
1378 __f_ = (__base*)&__buf_;
1379 __f.__f_->__clone(__f_);
1382 __f_ = __f.__f_->__clone();
1385 template<class _Rp, class _A0, class _A1, class _A2>
1386 template <class _Fp>
1387 function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
1388 typename enable_if<!is_integral<_Fp>::value>::type*)
1391 if (__function::__not_null(__f))
1393 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF;
1394 if (sizeof(_FF) <= sizeof(__buf_))
1396 __f_ = (__base*)&__buf_;
1397 ::new (__f_) _FF(__f);
1401 typedef allocator<_FF> _Ap;
1403 typedef __allocator_destructor<_Ap> _Dp;
1404 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1405 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
1406 __f_ = __hold.release();
1411 template<class _Rp, class _A0, class _A1, class _A2>
1412 template <class _Fp, class _Alloc>
1413 function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1414 typename enable_if<!is_integral<_Fp>::value>::type*)
1417 typedef allocator_traits<_Alloc> __alloc_traits;
1418 if (__function::__not_null(__f))
1420 typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF;
1421 if (sizeof(_FF) <= sizeof(__buf_))
1423 __f_ = (__base*)&__buf_;
1424 ::new (__f_) _FF(__f, __a0);
1428 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1430 typedef __allocator_destructor<_Ap> _Dp;
1431 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1432 ::new (__hold.get()) _FF(__f, _Alloc(__a));
1433 __f_ = __hold.release();
1438 template<class _Rp, class _A0, class _A1, class _A2>
1439 function<_Rp(_A0, _A1, _A2)>&
1440 function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
1443 function(__f).swap(*this);
1449 template<class _Rp, class _A0, class _A1, class _A2>
1450 function<_Rp(_A0, _A1, _A2)>&
1451 function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
1455 if (__t == (__base*)&__buf_)
1458 __t->destroy_deallocate();
1462 template<class _Rp, class _A0, class _A1, class _A2>
1463 template <class _Fp>
1466 !is_integral<_Fp>::value,
1467 function<_Rp(_A0, _A1, _A2)>&
1469 function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f)
1471 function(_VSTD::move(__f)).swap(*this);
1475 template<class _Rp, class _A0, class _A1, class _A2>
1476 function<_Rp(_A0, _A1, _A2)>::~function()
1478 if (__f_ == (__base*)&__buf_)
1481 __f_->destroy_deallocate();
1484 template<class _Rp, class _A0, class _A1, class _A2>
1486 function<_Rp(_A0, _A1, _A2)>::swap(function& __f)
1488 if (_VSTD::addressof(__f) == this)
1490 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1492 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1493 __base* __t = (__base*)&__tempbuf;
1497 __f.__f_->__clone((__base*)&__buf_);
1498 __f.__f_->destroy();
1500 __f_ = (__base*)&__buf_;
1501 __t->__clone((__base*)&__f.__buf_);
1503 __f.__f_ = (__base*)&__f.__buf_;
1505 else if (__f_ == (__base*)&__buf_)
1507 __f_->__clone((__base*)&__f.__buf_);
1510 __f.__f_ = (__base*)&__f.__buf_;
1512 else if (__f.__f_ == (__base*)&__f.__buf_)
1514 __f.__f_->__clone((__base*)&__buf_);
1515 __f.__f_->destroy();
1517 __f_ = (__base*)&__buf_;
1520 _VSTD::swap(__f_, __f.__f_);
1523 template<class _Rp, class _A0, class _A1, class _A2>
1525 function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
1528 __throw_bad_function_call();
1529 return (*__f_)(__a0, __a1, __a2);
1532 #ifndef _LIBCPP_NO_RTTI
1534 template<class _Rp, class _A0, class _A1, class _A2>
1535 const std::type_info&
1536 function<_Rp(_A0, _A1, _A2)>::target_type() const
1539 return typeid(void);
1540 return __f_->target_type();
1543 template<class _Rp, class _A0, class _A1, class _A2>
1544 template <typename _Tp>
1546 function<_Rp(_A0, _A1, _A2)>::target()
1550 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
1553 template<class _Rp, class _A0, class _A1, class _A2>
1554 template <typename _Tp>
1556 function<_Rp(_A0, _A1, _A2)>::target() const
1559 return (const _Tp*)0;
1560 return (const _Tp*)__f_->target(typeid(_Tp));
1563 #endif // _LIBCPP_NO_RTTI
1565 template <class _Fp>
1566 inline _LIBCPP_INLINE_VISIBILITY
1568 operator==(const function<_Fp>& __f, nullptr_t) {return !__f;}
1570 template <class _Fp>
1571 inline _LIBCPP_INLINE_VISIBILITY
1573 operator==(nullptr_t, const function<_Fp>& __f) {return !__f;}
1575 template <class _Fp>
1576 inline _LIBCPP_INLINE_VISIBILITY
1578 operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;}
1580 template <class _Fp>
1581 inline _LIBCPP_INLINE_VISIBILITY
1583 operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;}
1585 template <class _Fp>
1586 inline _LIBCPP_INLINE_VISIBILITY
1588 swap(function<_Fp>& __x, function<_Fp>& __y)
1589 {return __x.swap(__y);}
1591 #endif // _LIBCPP_FUNCTIONAL_03