xref: /netbsd-src/external/apache2/llvm/dist/libcxx/include/__functional_base (revision 4d6fc14bc9b0c5bf3e30be318c143ee82cadd108)
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
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
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_FUNCTIONAL_BASE
11#define _LIBCPP_FUNCTIONAL_BASE
12
13#include <__config>
14#include <type_traits>
15#include <typeinfo>
16#include <exception>
17#include <new>
18#include <utility>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21#pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26template <class _Arg1, class _Arg2, class _Result>
27struct _LIBCPP_TEMPLATE_VIS binary_function
28{
29    typedef _Arg1   first_argument_type;
30    typedef _Arg2   second_argument_type;
31    typedef _Result result_type;
32};
33
34template <class _Tp>
35struct __has_result_type
36{
37private:
38    struct __two {char __lx; char __lxx;};
39    template <class _Up> static __two __test(...);
40    template <class _Up> static char __test(typename _Up::result_type* = 0);
41public:
42    static const bool value = sizeof(__test<_Tp>(0)) == 1;
43};
44
45#if _LIBCPP_STD_VER > 11
46template <class _Tp = void>
47#else
48template <class _Tp>
49#endif
50struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool>
51{
52    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
53    bool operator()(const _Tp& __x, const _Tp& __y) const
54        {return __x < __y;}
55};
56
57#if _LIBCPP_STD_VER > 11
58template <>
59struct _LIBCPP_TEMPLATE_VIS less<void>
60{
61    template <class _T1, class _T2>
62    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
63    auto operator()(_T1&& __t, _T2&& __u) const
64    _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
65    -> decltype        (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
66        { return        _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
67    typedef void is_transparent;
68};
69#endif
70
71// __weak_result_type
72
73template <class _Tp>
74struct __derives_from_unary_function
75{
76private:
77    struct __two {char __lx; char __lxx;};
78    static __two __test(...);
79    template <class _Ap, class _Rp>
80        static unary_function<_Ap, _Rp>
81        __test(const volatile unary_function<_Ap, _Rp>*);
82public:
83    static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
84    typedef decltype(__test((_Tp*)0)) type;
85};
86
87template <class _Tp>
88struct __derives_from_binary_function
89{
90private:
91    struct __two {char __lx; char __lxx;};
92    static __two __test(...);
93    template <class _A1, class _A2, class _Rp>
94        static binary_function<_A1, _A2, _Rp>
95        __test(const volatile binary_function<_A1, _A2, _Rp>*);
96public:
97    static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
98    typedef decltype(__test((_Tp*)0)) type;
99};
100
101template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
102struct __maybe_derive_from_unary_function  // bool is true
103    : public __derives_from_unary_function<_Tp>::type
104{
105};
106
107template <class _Tp>
108struct __maybe_derive_from_unary_function<_Tp, false>
109{
110};
111
112template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
113struct __maybe_derive_from_binary_function  // bool is true
114    : public __derives_from_binary_function<_Tp>::type
115{
116};
117
118template <class _Tp>
119struct __maybe_derive_from_binary_function<_Tp, false>
120{
121};
122
123template <class _Tp, bool = __has_result_type<_Tp>::value>
124struct __weak_result_type_imp // bool is true
125    : public __maybe_derive_from_unary_function<_Tp>,
126      public __maybe_derive_from_binary_function<_Tp>
127{
128    typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type;
129};
130
131template <class _Tp>
132struct __weak_result_type_imp<_Tp, false>
133    : public __maybe_derive_from_unary_function<_Tp>,
134      public __maybe_derive_from_binary_function<_Tp>
135{
136};
137
138template <class _Tp>
139struct __weak_result_type
140    : public __weak_result_type_imp<_Tp>
141{
142};
143
144// 0 argument case
145
146template <class _Rp>
147struct __weak_result_type<_Rp ()>
148{
149    typedef _LIBCPP_NODEBUG_TYPE  _Rp result_type;
150};
151
152template <class _Rp>
153struct __weak_result_type<_Rp (&)()>
154{
155    typedef _LIBCPP_NODEBUG_TYPE  _Rp result_type;
156};
157
158template <class _Rp>
159struct __weak_result_type<_Rp (*)()>
160{
161    typedef _LIBCPP_NODEBUG_TYPE  _Rp result_type;
162};
163
164// 1 argument case
165
166template <class _Rp, class _A1>
167struct __weak_result_type<_Rp (_A1)>
168    : public unary_function<_A1, _Rp>
169{
170};
171
172template <class _Rp, class _A1>
173struct __weak_result_type<_Rp (&)(_A1)>
174    : public unary_function<_A1, _Rp>
175{
176};
177
178template <class _Rp, class _A1>
179struct __weak_result_type<_Rp (*)(_A1)>
180    : public unary_function<_A1, _Rp>
181{
182};
183
184template <class _Rp, class _Cp>
185struct __weak_result_type<_Rp (_Cp::*)()>
186    : public unary_function<_Cp*, _Rp>
187{
188};
189
190template <class _Rp, class _Cp>
191struct __weak_result_type<_Rp (_Cp::*)() const>
192    : public unary_function<const _Cp*, _Rp>
193{
194};
195
196template <class _Rp, class _Cp>
197struct __weak_result_type<_Rp (_Cp::*)() volatile>
198    : public unary_function<volatile _Cp*, _Rp>
199{
200};
201
202template <class _Rp, class _Cp>
203struct __weak_result_type<_Rp (_Cp::*)() const volatile>
204    : public unary_function<const volatile _Cp*, _Rp>
205{
206};
207
208// 2 argument case
209
210template <class _Rp, class _A1, class _A2>
211struct __weak_result_type<_Rp (_A1, _A2)>
212    : public binary_function<_A1, _A2, _Rp>
213{
214};
215
216template <class _Rp, class _A1, class _A2>
217struct __weak_result_type<_Rp (*)(_A1, _A2)>
218    : public binary_function<_A1, _A2, _Rp>
219{
220};
221
222template <class _Rp, class _A1, class _A2>
223struct __weak_result_type<_Rp (&)(_A1, _A2)>
224    : public binary_function<_A1, _A2, _Rp>
225{
226};
227
228template <class _Rp, class _Cp, class _A1>
229struct __weak_result_type<_Rp (_Cp::*)(_A1)>
230    : public binary_function<_Cp*, _A1, _Rp>
231{
232};
233
234template <class _Rp, class _Cp, class _A1>
235struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
236    : public binary_function<const _Cp*, _A1, _Rp>
237{
238};
239
240template <class _Rp, class _Cp, class _A1>
241struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
242    : public binary_function<volatile _Cp*, _A1, _Rp>
243{
244};
245
246template <class _Rp, class _Cp, class _A1>
247struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
248    : public binary_function<const volatile _Cp*, _A1, _Rp>
249{
250};
251
252
253#ifndef _LIBCPP_CXX03_LANG
254// 3 or more arguments
255
256template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
257struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
258{
259    typedef _Rp result_type;
260};
261
262template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
263struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
264{
265    typedef _Rp result_type;
266};
267
268template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
269struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
270{
271    typedef _Rp result_type;
272};
273
274template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
275struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
276{
277    typedef _Rp result_type;
278};
279
280template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
281struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
282{
283    typedef _Rp result_type;
284};
285
286template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
287struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
288{
289    typedef _Rp result_type;
290};
291
292template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
293struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
294{
295    typedef _Rp result_type;
296};
297
298template <class _Tp, class ..._Args>
299struct __invoke_return
300{
301    typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
302};
303
304#else // defined(_LIBCPP_CXX03_LANG)
305
306#include <__functional_base_03>
307
308#endif // !defined(_LIBCPP_CXX03_LANG)
309
310
311template <class _Ret, bool = is_void<_Ret>::value>
312struct __invoke_void_return_wrapper
313{
314#ifndef _LIBCPP_CXX03_LANG
315    template <class ..._Args>
316    static _Ret __call(_Args&&... __args) {
317        return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
318    }
319#else
320    template <class _Fn>
321    static _Ret __call(_Fn __f) {
322        return _VSTD::__invoke(__f);
323    }
324
325    template <class _Fn, class _A0>
326    static _Ret __call(_Fn __f, _A0& __a0) {
327        return _VSTD::__invoke(__f, __a0);
328    }
329
330    template <class _Fn, class _A0, class _A1>
331    static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
332        return _VSTD::__invoke(__f, __a0, __a1);
333    }
334
335    template <class _Fn, class _A0, class _A1, class _A2>
336    static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
337        return _VSTD::__invoke(__f, __a0, __a1, __a2);
338    }
339#endif
340};
341
342template <class _Ret>
343struct __invoke_void_return_wrapper<_Ret, true>
344{
345#ifndef _LIBCPP_CXX03_LANG
346    template <class ..._Args>
347    static void __call(_Args&&... __args) {
348        _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
349    }
350#else
351    template <class _Fn>
352    static void __call(_Fn __f) {
353        _VSTD::__invoke(__f);
354    }
355
356    template <class _Fn, class _A0>
357    static void __call(_Fn __f, _A0& __a0) {
358        _VSTD::__invoke(__f, __a0);
359    }
360
361    template <class _Fn, class _A0, class _A1>
362    static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
363        _VSTD::__invoke(__f, __a0, __a1);
364    }
365
366    template <class _Fn, class _A0, class _A1, class _A2>
367    static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
368        _VSTD::__invoke(__f, __a0, __a1, __a2);
369    }
370#endif
371};
372
373template <class _Tp>
374class _LIBCPP_TEMPLATE_VIS reference_wrapper
375    : public __weak_result_type<_Tp>
376{
377public:
378    // types
379    typedef _Tp type;
380private:
381    type* __f_;
382
383#ifndef _LIBCPP_CXX03_LANG
384    static void __fun(_Tp&) _NOEXCEPT;
385    static void __fun(_Tp&&) = delete;
386#endif
387
388public:
389    // construct/copy/destroy
390#ifdef _LIBCPP_CXX03_LANG
391    _LIBCPP_INLINE_VISIBILITY
392    reference_wrapper(type& __f) _NOEXCEPT
393        : __f_(_VSTD::addressof(__f)) {}
394#else
395    template <class _Up, class = _EnableIf<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) >>
396    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
397    reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) {
398        type& __f = static_cast<_Up&&>(__u);
399        __f_ = _VSTD::addressof(__f);
400    }
401#endif
402
403    // access
404    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
405    operator type&() const _NOEXCEPT {return *__f_;}
406    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
407    type& get() const _NOEXCEPT {return *__f_;}
408
409#ifndef _LIBCPP_CXX03_LANG
410    // invoke
411    template <class... _ArgTypes>
412    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
413    typename __invoke_of<type&, _ArgTypes...>::type
414    operator() (_ArgTypes&&... __args) const {
415        return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
416    }
417#else
418
419    _LIBCPP_INLINE_VISIBILITY
420    typename __invoke_return<type>::type
421    operator() () const {
422        return _VSTD::__invoke(get());
423    }
424
425    template <class _A0>
426    _LIBCPP_INLINE_VISIBILITY
427    typename __invoke_return0<type, _A0>::type
428    operator() (_A0& __a0) const {
429        return _VSTD::__invoke(get(), __a0);
430    }
431
432    template <class _A0>
433    _LIBCPP_INLINE_VISIBILITY
434    typename __invoke_return0<type, _A0 const>::type
435    operator() (_A0 const& __a0) const {
436        return _VSTD::__invoke(get(), __a0);
437    }
438
439    template <class _A0, class _A1>
440    _LIBCPP_INLINE_VISIBILITY
441    typename __invoke_return1<type, _A0, _A1>::type
442    operator() (_A0& __a0, _A1& __a1) const {
443        return _VSTD::__invoke(get(), __a0, __a1);
444    }
445
446    template <class _A0, class _A1>
447    _LIBCPP_INLINE_VISIBILITY
448    typename __invoke_return1<type, _A0 const, _A1>::type
449    operator() (_A0 const& __a0, _A1& __a1) const {
450        return _VSTD::__invoke(get(), __a0, __a1);
451    }
452
453    template <class _A0, class _A1>
454    _LIBCPP_INLINE_VISIBILITY
455    typename __invoke_return1<type, _A0, _A1 const>::type
456    operator() (_A0& __a0, _A1 const& __a1) const {
457        return _VSTD::__invoke(get(), __a0, __a1);
458    }
459
460    template <class _A0, class _A1>
461    _LIBCPP_INLINE_VISIBILITY
462    typename __invoke_return1<type, _A0 const, _A1 const>::type
463    operator() (_A0 const& __a0, _A1 const& __a1) const {
464        return _VSTD::__invoke(get(), __a0, __a1);
465    }
466
467    template <class _A0, class _A1, class _A2>
468    _LIBCPP_INLINE_VISIBILITY
469    typename __invoke_return2<type, _A0, _A1, _A2>::type
470    operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
471        return _VSTD::__invoke(get(), __a0, __a1, __a2);
472    }
473
474    template <class _A0, class _A1, class _A2>
475    _LIBCPP_INLINE_VISIBILITY
476    typename __invoke_return2<type, _A0 const, _A1, _A2>::type
477    operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
478        return _VSTD::__invoke(get(), __a0, __a1, __a2);
479    }
480
481    template <class _A0, class _A1, class _A2>
482    _LIBCPP_INLINE_VISIBILITY
483    typename __invoke_return2<type, _A0, _A1 const, _A2>::type
484    operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
485        return _VSTD::__invoke(get(), __a0, __a1, __a2);
486    }
487
488    template <class _A0, class _A1, class _A2>
489    _LIBCPP_INLINE_VISIBILITY
490    typename __invoke_return2<type, _A0, _A1, _A2 const>::type
491    operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
492        return _VSTD::__invoke(get(), __a0, __a1, __a2);
493    }
494
495    template <class _A0, class _A1, class _A2>
496    _LIBCPP_INLINE_VISIBILITY
497    typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
498    operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
499        return _VSTD::__invoke(get(), __a0, __a1, __a2);
500    }
501
502    template <class _A0, class _A1, class _A2>
503    _LIBCPP_INLINE_VISIBILITY
504    typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
505    operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
506        return _VSTD::__invoke(get(), __a0, __a1, __a2);
507    }
508
509    template <class _A0, class _A1, class _A2>
510    _LIBCPP_INLINE_VISIBILITY
511    typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
512    operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
513        return _VSTD::__invoke(get(), __a0, __a1, __a2);
514    }
515
516    template <class _A0, class _A1, class _A2>
517    _LIBCPP_INLINE_VISIBILITY
518    typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
519    operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
520        return _VSTD::__invoke(get(), __a0, __a1, __a2);
521    }
522#endif // _LIBCPP_CXX03_LANG
523};
524
525#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
526template <class _Tp>
527reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
528#endif
529
530template <class _Tp>
531inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
532reference_wrapper<_Tp>
533ref(_Tp& __t) _NOEXCEPT
534{
535    return reference_wrapper<_Tp>(__t);
536}
537
538template <class _Tp>
539inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
540reference_wrapper<_Tp>
541ref(reference_wrapper<_Tp> __t) _NOEXCEPT
542{
543    return _VSTD::ref(__t.get());
544}
545
546template <class _Tp>
547inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
548reference_wrapper<const _Tp>
549cref(const _Tp& __t) _NOEXCEPT
550{
551    return reference_wrapper<const _Tp>(__t);
552}
553
554template <class _Tp>
555inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
556reference_wrapper<const _Tp>
557cref(reference_wrapper<_Tp> __t) _NOEXCEPT
558{
559    return _VSTD::cref(__t.get());
560}
561
562#ifndef _LIBCPP_CXX03_LANG
563template <class _Tp> void ref(const _Tp&&) = delete;
564template <class _Tp> void cref(const _Tp&&) = delete;
565#endif
566
567#if _LIBCPP_STD_VER > 11
568template <class _Tp, class, class = void>
569struct __is_transparent : false_type {};
570
571template <class _Tp, class _Up>
572struct __is_transparent<_Tp, _Up,
573                        typename __void_t<typename _Tp::is_transparent>::type>
574   : true_type {};
575#endif
576
577// allocator_arg_t
578
579struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; };
580
581#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
582extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
583#else
584/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
585#endif
586
587// uses_allocator
588
589template <class _Tp>
590struct __has_allocator_type
591{
592private:
593    struct __two {char __lx; char __lxx;};
594    template <class _Up> static __two __test(...);
595    template <class _Up> static char __test(typename _Up::allocator_type* = 0);
596public:
597    static const bool value = sizeof(__test<_Tp>(0)) == 1;
598};
599
600template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
601struct __uses_allocator
602    : public integral_constant<bool,
603        is_convertible<_Alloc, typename _Tp::allocator_type>::value>
604{
605};
606
607template <class _Tp, class _Alloc>
608struct __uses_allocator<_Tp, _Alloc, false>
609    : public false_type
610{
611};
612
613template <class _Tp, class _Alloc>
614struct _LIBCPP_TEMPLATE_VIS uses_allocator
615    : public __uses_allocator<_Tp, _Alloc>
616{
617};
618
619#if _LIBCPP_STD_VER > 14
620template <class _Tp, class _Alloc>
621_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
622#endif
623
624#ifndef _LIBCPP_CXX03_LANG
625
626// allocator construction
627
628template <class _Tp, class _Alloc, class ..._Args>
629struct __uses_alloc_ctor_imp
630{
631    typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc;
632    static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
633    static const bool __ic =
634        is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
635    static const int value = __ua ? 2 - __ic : 0;
636};
637
638template <class _Tp, class _Alloc, class ..._Args>
639struct __uses_alloc_ctor
640    : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
641    {};
642
643template <class _Tp, class _Allocator, class... _Args>
644inline _LIBCPP_INLINE_VISIBILITY
645void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
646{
647    new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
648}
649
650// FIXME: This should have a version which takes a non-const alloc.
651template <class _Tp, class _Allocator, class... _Args>
652inline _LIBCPP_INLINE_VISIBILITY
653void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
654{
655    new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
656}
657
658// FIXME: This should have a version which takes a non-const alloc.
659template <class _Tp, class _Allocator, class... _Args>
660inline _LIBCPP_INLINE_VISIBILITY
661void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
662{
663    new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
664}
665
666#endif // _LIBCPP_CXX03_LANG
667
668#if _LIBCPP_STD_VER > 14
669
670template <class _Fn, class ..._Args>
671_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
672invoke(_Fn&& __f, _Args&&... __args)
673    noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
674{
675    return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
676}
677
678#endif // _LIBCPP_STD_VER > 14
679
680_LIBCPP_END_NAMESPACE_STD
681
682#endif // _LIBCPP_FUNCTIONAL_BASE
683