2 //===----------------------------------------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_FUNCTIONAL_03
12 #define _LIBCPP_FUNCTIONAL_03
14 // manual variadic expansion for <functional>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 #pragma GCC system_header
20 namespace __function {
22 template<class _Fp> class __base;
27 __base(const __base&);
28 __base& operator=(const __base&);
32 virtual __base* __clone() const = 0;
33 virtual void __clone(__base*) const = 0;
34 virtual void destroy() = 0;
35 virtual void destroy_deallocate() = 0;
36 virtual _Rp operator()() = 0;
37 #ifndef _LIBCPP_NO_RTTI
38 virtual const void* target(const type_info&) const = 0;
39 virtual const std::type_info& target_type() const = 0;
40 #endif // _LIBCPP_NO_RTTI
43 template<class _Rp, class _A0>
44 class __base<_Rp(_A0)>
46 __base(const __base&);
47 __base& operator=(const __base&);
51 virtual __base* __clone() const = 0;
52 virtual void __clone(__base*) const = 0;
53 virtual void destroy() = 0;
54 virtual void destroy_deallocate() = 0;
55 virtual _Rp operator()(_A0) = 0;
56 #ifndef _LIBCPP_NO_RTTI
57 virtual const void* target(const type_info&) const = 0;
58 virtual const std::type_info& target_type() const = 0;
59 #endif // _LIBCPP_NO_RTTI
62 template<class _Rp, class _A0, class _A1>
63 class __base<_Rp(_A0, _A1)>
65 __base(const __base&);
66 __base& operator=(const __base&);
70 virtual __base* __clone() const = 0;
71 virtual void __clone(__base*) const = 0;
72 virtual void destroy() = 0;
73 virtual void destroy_deallocate() = 0;
74 virtual _Rp operator()(_A0, _A1) = 0;
75 #ifndef _LIBCPP_NO_RTTI
76 virtual const void* target(const type_info&) const = 0;
77 virtual const std::type_info& target_type() const = 0;
78 #endif // _LIBCPP_NO_RTTI
81 template<class _Rp, class _A0, class _A1, class _A2>
82 class __base<_Rp(_A0, _A1, _A2)>
84 __base(const __base&);
85 __base& operator=(const __base&);
89 virtual __base* __clone() const = 0;
90 virtual void __clone(__base*) const = 0;
91 virtual void destroy() = 0;
92 virtual void destroy_deallocate() = 0;
93 virtual _Rp operator()(_A0, _A1, _A2) = 0;
94 #ifndef _LIBCPP_NO_RTTI
95 virtual const void* target(const type_info&) const = 0;
96 virtual const std::type_info& target_type() const = 0;
97 #endif // _LIBCPP_NO_RTTI
100 template<class _FD, class _Alloc, class _FB> class __func;
102 template<class _Fp, class _Alloc, class _Rp>
103 class __func<_Fp, _Alloc, _Rp()>
104 : public __base<_Rp()>
106 __compressed_pair<_Fp, _Alloc> __f_;
108 explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
109 explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
110 virtual __base<_Rp()>* __clone() const;
111 virtual void __clone(__base<_Rp()>*) const;
112 virtual void destroy();
113 virtual void destroy_deallocate();
114 virtual _Rp operator()();
115 #ifndef _LIBCPP_NO_RTTI
116 virtual const void* target(const type_info&) const;
117 virtual const std::type_info& target_type() const;
118 #endif // _LIBCPP_NO_RTTI
121 template<class _Fp, class _Alloc, class _Rp>
123 __func<_Fp, _Alloc, _Rp()>::__clone() const
125 typedef allocator_traits<_Alloc> __alloc_traits;
126 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
127 _Ap __a(__f_.second());
128 typedef __allocator_destructor<_Ap> _Dp;
129 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
130 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
131 return __hold.release();
134 template<class _Fp, class _Alloc, class _Rp>
136 __func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
138 ::new (__p) __func(__f_.first(), __f_.second());
141 template<class _Fp, class _Alloc, class _Rp>
143 __func<_Fp, _Alloc, _Rp()>::destroy()
145 __f_.~__compressed_pair<_Fp, _Alloc>();
148 template<class _Fp, class _Alloc, class _Rp>
150 __func<_Fp, _Alloc, _Rp()>::destroy_deallocate()
152 typedef allocator_traits<_Alloc> __alloc_traits;
153 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
154 _Ap __a(__f_.second());
155 __f_.~__compressed_pair<_Fp, _Alloc>();
156 __a.deallocate(this, 1);
159 template<class _Fp, class _Alloc, class _Rp>
161 __func<_Fp, _Alloc, _Rp()>::operator()()
163 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
164 return _Invoker::__call(__f_.first());
167 #ifndef _LIBCPP_NO_RTTI
169 template<class _Fp, class _Alloc, class _Rp>
171 __func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const
173 if (__ti == typeid(_Fp))
174 return &__f_.first();
175 return (const void*)0;
178 template<class _Fp, class _Alloc, class _Rp>
179 const std::type_info&
180 __func<_Fp, _Alloc, _Rp()>::target_type() const
185 #endif // _LIBCPP_NO_RTTI
187 template<class _Fp, class _Alloc, class _Rp, class _A0>
188 class __func<_Fp, _Alloc, _Rp(_A0)>
189 : public __base<_Rp(_A0)>
191 __compressed_pair<_Fp, _Alloc> __f_;
193 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
194 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
195 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
196 virtual __base<_Rp(_A0)>* __clone() const;
197 virtual void __clone(__base<_Rp(_A0)>*) const;
198 virtual void destroy();
199 virtual void destroy_deallocate();
200 virtual _Rp operator()(_A0);
201 #ifndef _LIBCPP_NO_RTTI
202 virtual const void* target(const type_info&) const;
203 virtual const std::type_info& target_type() const;
204 #endif // _LIBCPP_NO_RTTI
207 template<class _Fp, class _Alloc, class _Rp, class _A0>
209 __func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
211 typedef allocator_traits<_Alloc> __alloc_traits;
212 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
213 _Ap __a(__f_.second());
214 typedef __allocator_destructor<_Ap> _Dp;
215 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
216 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
217 return __hold.release();
220 template<class _Fp, class _Alloc, class _Rp, class _A0>
222 __func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
224 ::new (__p) __func(__f_.first(), __f_.second());
227 template<class _Fp, class _Alloc, class _Rp, class _A0>
229 __func<_Fp, _Alloc, _Rp(_A0)>::destroy()
231 __f_.~__compressed_pair<_Fp, _Alloc>();
234 template<class _Fp, class _Alloc, class _Rp, class _A0>
236 __func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate()
238 typedef allocator_traits<_Alloc> __alloc_traits;
239 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
240 _Ap __a(__f_.second());
241 __f_.~__compressed_pair<_Fp, _Alloc>();
242 __a.deallocate(this, 1);
245 template<class _Fp, class _Alloc, class _Rp, class _A0>
247 __func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0)
249 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
250 return _Invoker::__call(__f_.first(), __a0);
253 #ifndef _LIBCPP_NO_RTTI
255 template<class _Fp, class _Alloc, class _Rp, class _A0>
257 __func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const
259 if (__ti == typeid(_Fp))
260 return &__f_.first();
261 return (const void*)0;
264 template<class _Fp, class _Alloc, class _Rp, class _A0>
265 const std::type_info&
266 __func<_Fp, _Alloc, _Rp(_A0)>::target_type() const
271 #endif // _LIBCPP_NO_RTTI
273 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
274 class __func<_Fp, _Alloc, _Rp(_A0, _A1)>
275 : public __base<_Rp(_A0, _A1)>
277 __compressed_pair<_Fp, _Alloc> __f_;
279 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
280 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
281 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
282 virtual __base<_Rp(_A0, _A1)>* __clone() const;
283 virtual void __clone(__base<_Rp(_A0, _A1)>*) const;
284 virtual void destroy();
285 virtual void destroy_deallocate();
286 virtual _Rp operator()(_A0, _A1);
287 #ifndef _LIBCPP_NO_RTTI
288 virtual const void* target(const type_info&) const;
289 virtual const std::type_info& target_type() const;
290 #endif // _LIBCPP_NO_RTTI
293 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
294 __base<_Rp(_A0, _A1)>*
295 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
297 typedef allocator_traits<_Alloc> __alloc_traits;
298 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
299 _Ap __a(__f_.second());
300 typedef __allocator_destructor<_Ap> _Dp;
301 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
302 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
303 return __hold.release();
306 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
308 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
310 ::new (__p) __func(__f_.first(), __f_.second());
313 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
315 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy()
317 __f_.~__compressed_pair<_Fp, _Alloc>();
320 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
322 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate()
324 typedef allocator_traits<_Alloc> __alloc_traits;
325 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
326 _Ap __a(__f_.second());
327 __f_.~__compressed_pair<_Fp, _Alloc>();
328 __a.deallocate(this, 1);
331 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
333 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1)
335 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
336 return _Invoker::__call(__f_.first(), __a0, __a1);
339 #ifndef _LIBCPP_NO_RTTI
341 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
343 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const
345 if (__ti == typeid(_Fp))
346 return &__f_.first();
347 return (const void*)0;
350 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
351 const std::type_info&
352 __func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const
357 #endif // _LIBCPP_NO_RTTI
359 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
360 class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>
361 : public __base<_Rp(_A0, _A1, _A2)>
363 __compressed_pair<_Fp, _Alloc> __f_;
365 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
366 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
367 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
368 virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const;
369 virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const;
370 virtual void destroy();
371 virtual void destroy_deallocate();
372 virtual _Rp operator()(_A0, _A1, _A2);
373 #ifndef _LIBCPP_NO_RTTI
374 virtual const void* target(const type_info&) const;
375 virtual const std::type_info& target_type() const;
376 #endif // _LIBCPP_NO_RTTI
379 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
380 __base<_Rp(_A0, _A1, _A2)>*
381 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
383 typedef allocator_traits<_Alloc> __alloc_traits;
384 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
385 _Ap __a(__f_.second());
386 typedef __allocator_destructor<_Ap> _Dp;
387 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
388 ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
389 return __hold.release();
392 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
394 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
396 ::new (__p) __func(__f_.first(), __f_.second());
399 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
401 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy()
403 __f_.~__compressed_pair<_Fp, _Alloc>();
406 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
408 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate()
410 typedef allocator_traits<_Alloc> __alloc_traits;
411 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
412 _Ap __a(__f_.second());
413 __f_.~__compressed_pair<_Fp, _Alloc>();
414 __a.deallocate(this, 1);
417 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
419 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2)
421 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
422 return _Invoker::__call(__f_.first(), __a0, __a1, __a2);
425 #ifndef _LIBCPP_NO_RTTI
427 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
429 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const
431 if (__ti == typeid(_Fp))
432 return &__f_.first();
433 return (const void*)0;
436 template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
437 const std::type_info&
438 __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const
443 #endif // _LIBCPP_NO_RTTI
448 class _LIBCPP_TYPE_VIS_ONLY function<_Rp()>
450 typedef __function::__base<_Rp()> __base;
451 aligned_storage<3*sizeof(void*)>::type __buf_;
455 typedef _Rp result_type;
457 // 20.7.16.2.1, construct/copy/destroy:
458 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
459 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
460 function(const function&);
463 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
465 template<class _Alloc>
466 _LIBCPP_INLINE_VISIBILITY
467 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
468 template<class _Alloc>
469 _LIBCPP_INLINE_VISIBILITY
470 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
471 template<class _Alloc>
472 function(allocator_arg_t, const _Alloc&, const function&);
473 template<class _Fp, class _Alloc>
474 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
475 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
477 function& operator=(const function&);
478 function& operator=(nullptr_t);
482 !is_integral<_Fp>::value,
489 // 20.7.16.2.2, function modifiers:
490 void swap(function&);
491 template<class _Fp, class _Alloc>
492 _LIBCPP_INLINE_VISIBILITY
493 void assign(_Fp __f, const _Alloc& __a)
494 {function(allocator_arg, __a, __f).swap(*this);}
496 // 20.7.16.2.3, function capacity:
497 _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
500 // deleted overloads close possible hole in the type system
502 bool operator==(const function<_R2()>&) const;// = delete;
504 bool operator!=(const function<_R2()>&) const;// = delete;
506 // 20.7.16.2.4, function invocation:
507 _Rp operator()() const;
509 #ifndef _LIBCPP_NO_RTTI
510 // 20.7.16.2.5, function target access:
511 const std::type_info& target_type() const;
512 template <typename _Tp> _Tp* target();
513 template <typename _Tp> const _Tp* target() const;
514 #endif // _LIBCPP_NO_RTTI
518 function<_Rp()>::function(const function& __f)
522 else if (__f.__f_ == (const __base*)&__f.__buf_)
524 __f_ = (__base*)&__buf_;
525 __f.__f_->__clone(__f_);
528 __f_ = __f.__f_->__clone();
532 template<class _Alloc>
533 function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f)
537 else if (__f.__f_ == (const __base*)&__f.__buf_)
539 __f_ = (__base*)&__buf_;
540 __f.__f_->__clone(__f_);
543 __f_ = __f.__f_->__clone();
548 function<_Rp()>::function(_Fp __f,
549 typename enable_if<!is_integral<_Fp>::value>::type*)
552 if (__function::__not_null(__f))
554 typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF;
555 if (sizeof(_FF) <= sizeof(__buf_))
557 __f_ = (__base*)&__buf_;
558 ::new (__f_) _FF(__f);
562 typedef allocator<_FF> _Ap;
564 typedef __allocator_destructor<_Ap> _Dp;
565 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
566 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
567 __f_ = __hold.release();
573 template <class _Fp, class _Alloc>
574 function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
575 typename enable_if<!is_integral<_Fp>::value>::type*)
578 typedef allocator_traits<_Alloc> __alloc_traits;
579 if (__function::__not_null(__f))
581 typedef __function::__func<_Fp, _Alloc, _Rp()> _FF;
582 if (sizeof(_FF) <= sizeof(__buf_))
584 __f_ = (__base*)&__buf_;
585 ::new (__f_) _FF(__f, __a0);
589 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
591 typedef __allocator_destructor<_Ap> _Dp;
592 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
593 ::new (__hold.get()) _FF(__f, _Alloc(__a));
594 __f_ = __hold.release();
601 function<_Rp()>::operator=(const function& __f)
603 function(__f).swap(*this);
609 function<_Rp()>::operator=(nullptr_t)
611 if (__f_ == (__base*)&__buf_)
614 __f_->destroy_deallocate();
623 !is_integral<_Fp>::value,
626 function<_Rp()>::operator=(_Fp __f)
628 function(_VSTD::move(__f)).swap(*this);
633 function<_Rp()>::~function()
635 if (__f_ == (__base*)&__buf_)
638 __f_->destroy_deallocate();
643 function<_Rp()>::swap(function& __f)
645 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
647 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
648 __base* __t = (__base*)&__tempbuf;
652 __f.__f_->__clone((__base*)&__buf_);
655 __f_ = (__base*)&__buf_;
656 __t->__clone((__base*)&__f.__buf_);
658 __f.__f_ = (__base*)&__f.__buf_;
660 else if (__f_ == (__base*)&__buf_)
662 __f_->__clone((__base*)&__f.__buf_);
665 __f.__f_ = (__base*)&__f.__buf_;
667 else if (__f.__f_ == (__base*)&__f.__buf_)
669 __f.__f_->__clone((__base*)&__buf_);
672 __f_ = (__base*)&__buf_;
675 _VSTD::swap(__f_, __f.__f_);
680 function<_Rp()>::operator()() const
682 #ifndef _LIBCPP_NO_EXCEPTIONS
684 throw bad_function_call();
685 #endif // _LIBCPP_NO_EXCEPTIONS
689 #ifndef _LIBCPP_NO_RTTI
692 const std::type_info&
693 function<_Rp()>::target_type() const
697 return __f_->target_type();
701 template <typename _Tp>
703 function<_Rp()>::target()
707 return (_Tp*)__f_->target(typeid(_Tp));
711 template <typename _Tp>
713 function<_Rp()>::target() const
716 return (const _Tp*)0;
717 return (const _Tp*)__f_->target(typeid(_Tp));
720 #endif // _LIBCPP_NO_RTTI
722 template<class _Rp, class _A0>
723 class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)>
724 : public unary_function<_A0, _Rp>
726 typedef __function::__base<_Rp(_A0)> __base;
727 aligned_storage<3*sizeof(void*)>::type __buf_;
731 typedef _Rp result_type;
733 // 20.7.16.2.1, construct/copy/destroy:
734 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
735 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
736 function(const function&);
739 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
741 template<class _Alloc>
742 _LIBCPP_INLINE_VISIBILITY
743 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
744 template<class _Alloc>
745 _LIBCPP_INLINE_VISIBILITY
746 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
747 template<class _Alloc>
748 function(allocator_arg_t, const _Alloc&, const function&);
749 template<class _Fp, class _Alloc>
750 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
751 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
753 function& operator=(const function&);
754 function& operator=(nullptr_t);
758 !is_integral<_Fp>::value,
765 // 20.7.16.2.2, function modifiers:
766 void swap(function&);
767 template<class _Fp, class _Alloc>
768 _LIBCPP_INLINE_VISIBILITY
769 void assign(_Fp __f, const _Alloc& __a)
770 {function(allocator_arg, __a, __f).swap(*this);}
772 // 20.7.16.2.3, function capacity:
773 _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
776 // deleted overloads close possible hole in the type system
777 template<class _R2, class _B0>
778 bool operator==(const function<_R2(_B0)>&) const;// = delete;
779 template<class _R2, class _B0>
780 bool operator!=(const function<_R2(_B0)>&) const;// = delete;
782 // 20.7.16.2.4, function invocation:
783 _Rp operator()(_A0) const;
785 #ifndef _LIBCPP_NO_RTTI
786 // 20.7.16.2.5, function target access:
787 const std::type_info& target_type() const;
788 template <typename _Tp> _Tp* target();
789 template <typename _Tp> const _Tp* target() const;
790 #endif // _LIBCPP_NO_RTTI
793 template<class _Rp, class _A0>
794 function<_Rp(_A0)>::function(const function& __f)
798 else if (__f.__f_ == (const __base*)&__f.__buf_)
800 __f_ = (__base*)&__buf_;
801 __f.__f_->__clone(__f_);
804 __f_ = __f.__f_->__clone();
807 template<class _Rp, class _A0>
808 template<class _Alloc>
809 function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f)
813 else if (__f.__f_ == (const __base*)&__f.__buf_)
815 __f_ = (__base*)&__buf_;
816 __f.__f_->__clone(__f_);
819 __f_ = __f.__f_->__clone();
822 template<class _Rp, class _A0>
824 function<_Rp(_A0)>::function(_Fp __f,
825 typename enable_if<!is_integral<_Fp>::value>::type*)
828 if (__function::__not_null(__f))
830 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF;
831 if (sizeof(_FF) <= sizeof(__buf_))
833 __f_ = (__base*)&__buf_;
834 ::new (__f_) _FF(__f);
838 typedef allocator<_FF> _Ap;
840 typedef __allocator_destructor<_Ap> _Dp;
841 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
842 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
843 __f_ = __hold.release();
848 template<class _Rp, class _A0>
849 template <class _Fp, class _Alloc>
850 function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
851 typename enable_if<!is_integral<_Fp>::value>::type*)
854 typedef allocator_traits<_Alloc> __alloc_traits;
855 if (__function::__not_null(__f))
857 typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF;
858 if (sizeof(_FF) <= sizeof(__buf_))
860 __f_ = (__base*)&__buf_;
861 ::new (__f_) _FF(__f, __a0);
865 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
867 typedef __allocator_destructor<_Ap> _Dp;
868 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
869 ::new (__hold.get()) _FF(__f, _Alloc(__a));
870 __f_ = __hold.release();
875 template<class _Rp, class _A0>
877 function<_Rp(_A0)>::operator=(const function& __f)
879 function(__f).swap(*this);
883 template<class _Rp, class _A0>
885 function<_Rp(_A0)>::operator=(nullptr_t)
887 if (__f_ == (__base*)&__buf_)
890 __f_->destroy_deallocate();
895 template<class _Rp, class _A0>
899 !is_integral<_Fp>::value,
902 function<_Rp(_A0)>::operator=(_Fp __f)
904 function(_VSTD::move(__f)).swap(*this);
908 template<class _Rp, class _A0>
909 function<_Rp(_A0)>::~function()
911 if (__f_ == (__base*)&__buf_)
914 __f_->destroy_deallocate();
917 template<class _Rp, class _A0>
919 function<_Rp(_A0)>::swap(function& __f)
921 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
923 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
924 __base* __t = (__base*)&__tempbuf;
928 __f.__f_->__clone((__base*)&__buf_);
931 __f_ = (__base*)&__buf_;
932 __t->__clone((__base*)&__f.__buf_);
934 __f.__f_ = (__base*)&__f.__buf_;
936 else if (__f_ == (__base*)&__buf_)
938 __f_->__clone((__base*)&__f.__buf_);
941 __f.__f_ = (__base*)&__f.__buf_;
943 else if (__f.__f_ == (__base*)&__f.__buf_)
945 __f.__f_->__clone((__base*)&__buf_);
948 __f_ = (__base*)&__buf_;
951 _VSTD::swap(__f_, __f.__f_);
954 template<class _Rp, class _A0>
956 function<_Rp(_A0)>::operator()(_A0 __a0) const
958 #ifndef _LIBCPP_NO_EXCEPTIONS
960 throw bad_function_call();
961 #endif // _LIBCPP_NO_EXCEPTIONS
962 return (*__f_)(__a0);
965 #ifndef _LIBCPP_NO_RTTI
967 template<class _Rp, class _A0>
968 const std::type_info&
969 function<_Rp(_A0)>::target_type() const
973 return __f_->target_type();
976 template<class _Rp, class _A0>
977 template <typename _Tp>
979 function<_Rp(_A0)>::target()
983 return (_Tp*)__f_->target(typeid(_Tp));
986 template<class _Rp, class _A0>
987 template <typename _Tp>
989 function<_Rp(_A0)>::target() const
992 return (const _Tp*)0;
993 return (const _Tp*)__f_->target(typeid(_Tp));
996 #endif // _LIBCPP_NO_RTTI
998 template<class _Rp, class _A0, class _A1>
999 class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)>
1000 : public binary_function<_A0, _A1, _Rp>
1002 typedef __function::__base<_Rp(_A0, _A1)> __base;
1003 aligned_storage<3*sizeof(void*)>::type __buf_;
1007 typedef _Rp result_type;
1009 // 20.7.16.2.1, construct/copy/destroy:
1010 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
1011 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
1012 function(const function&);
1015 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1017 template<class _Alloc>
1018 _LIBCPP_INLINE_VISIBILITY
1019 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
1020 template<class _Alloc>
1021 _LIBCPP_INLINE_VISIBILITY
1022 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
1023 template<class _Alloc>
1024 function(allocator_arg_t, const _Alloc&, const function&);
1025 template<class _Fp, class _Alloc>
1026 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1027 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1029 function& operator=(const function&);
1030 function& operator=(nullptr_t);
1034 !is_integral<_Fp>::value,
1041 // 20.7.16.2.2, function modifiers:
1042 void swap(function&);
1043 template<class _Fp, class _Alloc>
1044 _LIBCPP_INLINE_VISIBILITY
1045 void assign(_Fp __f, const _Alloc& __a)
1046 {function(allocator_arg, __a, __f).swap(*this);}
1048 // 20.7.16.2.3, function capacity:
1049 operator bool() const {return __f_;}
1052 // deleted overloads close possible hole in the type system
1053 template<class _R2, class _B0, class _B1>
1054 bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete;
1055 template<class _R2, class _B0, class _B1>
1056 bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete;
1058 // 20.7.16.2.4, function invocation:
1059 _Rp operator()(_A0, _A1) const;
1061 #ifndef _LIBCPP_NO_RTTI
1062 // 20.7.16.2.5, function target access:
1063 const std::type_info& target_type() const;
1064 template <typename _Tp> _Tp* target();
1065 template <typename _Tp> const _Tp* target() const;
1066 #endif // _LIBCPP_NO_RTTI
1069 template<class _Rp, class _A0, class _A1>
1070 function<_Rp(_A0, _A1)>::function(const function& __f)
1074 else if (__f.__f_ == (const __base*)&__f.__buf_)
1076 __f_ = (__base*)&__buf_;
1077 __f.__f_->__clone(__f_);
1080 __f_ = __f.__f_->__clone();
1083 template<class _Rp, class _A0, class _A1>
1084 template<class _Alloc>
1085 function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f)
1089 else if (__f.__f_ == (const __base*)&__f.__buf_)
1091 __f_ = (__base*)&__buf_;
1092 __f.__f_->__clone(__f_);
1095 __f_ = __f.__f_->__clone();
1098 template<class _Rp, class _A0, class _A1>
1099 template <class _Fp>
1100 function<_Rp(_A0, _A1)>::function(_Fp __f,
1101 typename enable_if<!is_integral<_Fp>::value>::type*)
1104 if (__function::__not_null(__f))
1106 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF;
1107 if (sizeof(_FF) <= sizeof(__buf_))
1109 __f_ = (__base*)&__buf_;
1110 ::new (__f_) _FF(__f);
1114 typedef allocator<_FF> _Ap;
1116 typedef __allocator_destructor<_Ap> _Dp;
1117 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1118 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
1119 __f_ = __hold.release();
1124 template<class _Rp, class _A0, class _A1>
1125 template <class _Fp, class _Alloc>
1126 function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1127 typename enable_if<!is_integral<_Fp>::value>::type*)
1130 typedef allocator_traits<_Alloc> __alloc_traits;
1131 if (__function::__not_null(__f))
1133 typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF;
1134 if (sizeof(_FF) <= sizeof(__buf_))
1136 __f_ = (__base*)&__buf_;
1137 ::new (__f_) _FF(__f, __a0);
1141 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1143 typedef __allocator_destructor<_Ap> _Dp;
1144 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1145 ::new (__hold.get()) _FF(__f, _Alloc(__a));
1146 __f_ = __hold.release();
1151 template<class _Rp, class _A0, class _A1>
1152 function<_Rp(_A0, _A1)>&
1153 function<_Rp(_A0, _A1)>::operator=(const function& __f)
1155 function(__f).swap(*this);
1159 template<class _Rp, class _A0, class _A1>
1160 function<_Rp(_A0, _A1)>&
1161 function<_Rp(_A0, _A1)>::operator=(nullptr_t)
1163 if (__f_ == (__base*)&__buf_)
1166 __f_->destroy_deallocate();
1171 template<class _Rp, class _A0, class _A1>
1172 template <class _Fp>
1175 !is_integral<_Fp>::value,
1176 function<_Rp(_A0, _A1)>&
1178 function<_Rp(_A0, _A1)>::operator=(_Fp __f)
1180 function(_VSTD::move(__f)).swap(*this);
1184 template<class _Rp, class _A0, class _A1>
1185 function<_Rp(_A0, _A1)>::~function()
1187 if (__f_ == (__base*)&__buf_)
1190 __f_->destroy_deallocate();
1193 template<class _Rp, class _A0, class _A1>
1195 function<_Rp(_A0, _A1)>::swap(function& __f)
1197 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1199 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1200 __base* __t = (__base*)&__tempbuf;
1204 __f.__f_->__clone((__base*)&__buf_);
1205 __f.__f_->destroy();
1207 __f_ = (__base*)&__buf_;
1208 __t->__clone((__base*)&__f.__buf_);
1210 __f.__f_ = (__base*)&__f.__buf_;
1212 else if (__f_ == (__base*)&__buf_)
1214 __f_->__clone((__base*)&__f.__buf_);
1217 __f.__f_ = (__base*)&__f.__buf_;
1219 else if (__f.__f_ == (__base*)&__f.__buf_)
1221 __f.__f_->__clone((__base*)&__buf_);
1222 __f.__f_->destroy();
1224 __f_ = (__base*)&__buf_;
1227 _VSTD::swap(__f_, __f.__f_);
1230 template<class _Rp, class _A0, class _A1>
1232 function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
1234 #ifndef _LIBCPP_NO_EXCEPTIONS
1236 throw bad_function_call();
1237 #endif // _LIBCPP_NO_EXCEPTIONS
1238 return (*__f_)(__a0, __a1);
1241 #ifndef _LIBCPP_NO_RTTI
1243 template<class _Rp, class _A0, class _A1>
1244 const std::type_info&
1245 function<_Rp(_A0, _A1)>::target_type() const
1248 return typeid(void);
1249 return __f_->target_type();
1252 template<class _Rp, class _A0, class _A1>
1253 template <typename _Tp>
1255 function<_Rp(_A0, _A1)>::target()
1259 return (_Tp*)__f_->target(typeid(_Tp));
1262 template<class _Rp, class _A0, class _A1>
1263 template <typename _Tp>
1265 function<_Rp(_A0, _A1)>::target() const
1268 return (const _Tp*)0;
1269 return (const _Tp*)__f_->target(typeid(_Tp));
1272 #endif // _LIBCPP_NO_RTTI
1274 template<class _Rp, class _A0, class _A1, class _A2>
1275 class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)>
1277 typedef __function::__base<_Rp(_A0, _A1, _A2)> __base;
1278 aligned_storage<3*sizeof(void*)>::type __buf_;
1282 typedef _Rp result_type;
1284 // 20.7.16.2.1, construct/copy/destroy:
1285 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
1286 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
1287 function(const function&);
1290 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1292 template<class _Alloc>
1293 _LIBCPP_INLINE_VISIBILITY
1294 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
1295 template<class _Alloc>
1296 _LIBCPP_INLINE_VISIBILITY
1297 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
1298 template<class _Alloc>
1299 function(allocator_arg_t, const _Alloc&, const function&);
1300 template<class _Fp, class _Alloc>
1301 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1302 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1304 function& operator=(const function&);
1305 function& operator=(nullptr_t);
1309 !is_integral<_Fp>::value,
1316 // 20.7.16.2.2, function modifiers:
1317 void swap(function&);
1318 template<class _Fp, class _Alloc>
1319 _LIBCPP_INLINE_VISIBILITY
1320 void assign(_Fp __f, const _Alloc& __a)
1321 {function(allocator_arg, __a, __f).swap(*this);}
1323 // 20.7.16.2.3, function capacity:
1324 _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
1327 // deleted overloads close possible hole in the type system
1328 template<class _R2, class _B0, class _B1, class _B2>
1329 bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete;
1330 template<class _R2, class _B0, class _B1, class _B2>
1331 bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete;
1333 // 20.7.16.2.4, function invocation:
1334 _Rp operator()(_A0, _A1, _A2) const;
1336 #ifndef _LIBCPP_NO_RTTI
1337 // 20.7.16.2.5, function target access:
1338 const std::type_info& target_type() const;
1339 template <typename _Tp> _Tp* target();
1340 template <typename _Tp> const _Tp* target() const;
1341 #endif // _LIBCPP_NO_RTTI
1344 template<class _Rp, class _A0, class _A1, class _A2>
1345 function<_Rp(_A0, _A1, _A2)>::function(const function& __f)
1349 else if (__f.__f_ == (const __base*)&__f.__buf_)
1351 __f_ = (__base*)&__buf_;
1352 __f.__f_->__clone(__f_);
1355 __f_ = __f.__f_->__clone();
1358 template<class _Rp, class _A0, class _A1, class _A2>
1359 template<class _Alloc>
1360 function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&,
1361 const function& __f)
1365 else if (__f.__f_ == (const __base*)&__f.__buf_)
1367 __f_ = (__base*)&__buf_;
1368 __f.__f_->__clone(__f_);
1371 __f_ = __f.__f_->__clone();
1374 template<class _Rp, class _A0, class _A1, class _A2>
1375 template <class _Fp>
1376 function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
1377 typename enable_if<!is_integral<_Fp>::value>::type*)
1380 if (__function::__not_null(__f))
1382 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF;
1383 if (sizeof(_FF) <= sizeof(__buf_))
1385 __f_ = (__base*)&__buf_;
1386 ::new (__f_) _FF(__f);
1390 typedef allocator<_FF> _Ap;
1392 typedef __allocator_destructor<_Ap> _Dp;
1393 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1394 ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
1395 __f_ = __hold.release();
1400 template<class _Rp, class _A0, class _A1, class _A2>
1401 template <class _Fp, class _Alloc>
1402 function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1403 typename enable_if<!is_integral<_Fp>::value>::type*)
1406 typedef allocator_traits<_Alloc> __alloc_traits;
1407 if (__function::__not_null(__f))
1409 typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF;
1410 if (sizeof(_FF) <= sizeof(__buf_))
1412 __f_ = (__base*)&__buf_;
1413 ::new (__f_) _FF(__f, __a0);
1417 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1419 typedef __allocator_destructor<_Ap> _Dp;
1420 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1421 ::new (__hold.get()) _FF(__f, _Alloc(__a));
1422 __f_ = __hold.release();
1427 template<class _Rp, class _A0, class _A1, class _A2>
1428 function<_Rp(_A0, _A1, _A2)>&
1429 function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
1431 function(__f).swap(*this);
1435 template<class _Rp, class _A0, class _A1, class _A2>
1436 function<_Rp(_A0, _A1, _A2)>&
1437 function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
1439 if (__f_ == (__base*)&__buf_)
1442 __f_->destroy_deallocate();
1447 template<class _Rp, class _A0, class _A1, class _A2>
1448 template <class _Fp>
1451 !is_integral<_Fp>::value,
1452 function<_Rp(_A0, _A1, _A2)>&
1454 function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f)
1456 function(_VSTD::move(__f)).swap(*this);
1460 template<class _Rp, class _A0, class _A1, class _A2>
1461 function<_Rp(_A0, _A1, _A2)>::~function()
1463 if (__f_ == (__base*)&__buf_)
1466 __f_->destroy_deallocate();
1469 template<class _Rp, class _A0, class _A1, class _A2>
1471 function<_Rp(_A0, _A1, _A2)>::swap(function& __f)
1473 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1475 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1476 __base* __t = (__base*)&__tempbuf;
1480 __f.__f_->__clone((__base*)&__buf_);
1481 __f.__f_->destroy();
1483 __f_ = (__base*)&__buf_;
1484 __t->__clone((__base*)&__f.__buf_);
1486 __f.__f_ = (__base*)&__f.__buf_;
1488 else if (__f_ == (__base*)&__buf_)
1490 __f_->__clone((__base*)&__f.__buf_);
1493 __f.__f_ = (__base*)&__f.__buf_;
1495 else if (__f.__f_ == (__base*)&__f.__buf_)
1497 __f.__f_->__clone((__base*)&__buf_);
1498 __f.__f_->destroy();
1500 __f_ = (__base*)&__buf_;
1503 _VSTD::swap(__f_, __f.__f_);
1506 template<class _Rp, class _A0, class _A1, class _A2>
1508 function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
1510 #ifndef _LIBCPP_NO_EXCEPTIONS
1512 throw bad_function_call();
1513 #endif // _LIBCPP_NO_EXCEPTIONS
1514 return (*__f_)(__a0, __a1, __a2);
1517 #ifndef _LIBCPP_NO_RTTI
1519 template<class _Rp, class _A0, class _A1, class _A2>
1520 const std::type_info&
1521 function<_Rp(_A0, _A1, _A2)>::target_type() const
1524 return typeid(void);
1525 return __f_->target_type();
1528 template<class _Rp, class _A0, class _A1, class _A2>
1529 template <typename _Tp>
1531 function<_Rp(_A0, _A1, _A2)>::target()
1535 return (_Tp*)__f_->target(typeid(_Tp));
1538 template<class _Rp, class _A0, class _A1, class _A2>
1539 template <typename _Tp>
1541 function<_Rp(_A0, _A1, _A2)>::target() const
1544 return (const _Tp*)0;
1545 return (const _Tp*)__f_->target(typeid(_Tp));
1548 #endif // _LIBCPP_NO_RTTI
1550 template <class _Fp>
1551 inline _LIBCPP_INLINE_VISIBILITY
1553 operator==(const function<_Fp>& __f, nullptr_t) {return !__f;}
1555 template <class _Fp>
1556 inline _LIBCPP_INLINE_VISIBILITY
1558 operator==(nullptr_t, const function<_Fp>& __f) {return !__f;}
1560 template <class _Fp>
1561 inline _LIBCPP_INLINE_VISIBILITY
1563 operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;}
1565 template <class _Fp>
1566 inline _LIBCPP_INLINE_VISIBILITY
1568 operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;}
1570 template <class _Fp>
1571 inline _LIBCPP_INLINE_VISIBILITY
1573 swap(function<_Fp>& __x, function<_Fp>& __y)
1574 {return __x.swap(__y);}
1576 #endif // _LIBCPP_FUNCTIONAL_03