NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
bind.hpp
浏览该文件的文档.
1#ifndef NEFORCE_CORE_FUNCTIONAL_BIND_HPP__
2#define NEFORCE_CORE_FUNCTIONAL_BIND_HPP__
3
10
12NEFORCE_BEGIN_NAMESPACE__
13
15NEFORCE_BEGIN_INNER__
16
17template <typename Res, typename... Args>
18struct unary_or_binary_function {};
19
20template <typename Res, typename T1>
21struct unary_or_binary_function<Res, T1> : _NEFORCE unary_function<T1, Res> {};
22
23template <typename Res, typename T1, typename T2>
24struct unary_or_binary_function<Res, T1, T2> : _NEFORCE binary_function<T1, T2, Res> {};
25
26
31template <typename Sign>
32struct mem_func_traits;
33
34template <typename Res, typename Class, typename... Args>
35struct mem_func_traits_base {
36 using result_type = Res;
37 using maybe_type = unary_or_binary_function<Res, Class*, Args...>;
38 using arity = integral_constant<size_t, sizeof...(Args)>;
39};
40
41#define __NEFORCE_MEMFUNC_TRAITS_BASE(CV, REF) \
42 template <typename Res, typename Class, typename... Args> \
43 struct mem_func_traits<Res (Class::*)(Args...) CV REF> : mem_func_traits_base<Res, CV Class, Args...> { \
44 using vararg = false_type; \
45 }; \
46 template <typename Res, typename Class, typename... Args> \
47 struct mem_func_traits<Res (Class::*)(Args..., ...) CV REF> : mem_func_traits_base<Res, CV Class, Args...> { \
48 using vararg = true_type; \
49 };
50
51#define __NEFORCE_MEMFUNC_TRAITS(REF, P) \
52 __NEFORCE_MEMFUNC_TRAITS_BASE(, REF) \
53 __NEFORCE_MEMFUNC_TRAITS_BASE(const, REF) \
54 __NEFORCE_MEMFUNC_TRAITS_BASE(volatile, REF) \
55 __NEFORCE_MEMFUNC_TRAITS_BASE(const volatile, REF)
56
57__NEFORCE_MEMFUNC_TRAITS(, )
58__NEFORCE_MEMFUNC_TRAITS(&, )
59__NEFORCE_MEMFUNC_TRAITS(&&, )
60
61#ifdef NEFORCE_STANDARD_17
62__NEFORCE_MEMFUNC_TRAITS(noexcept, )
63__NEFORCE_MEMFUNC_TRAITS(& noexcept, )
64__NEFORCE_MEMFUNC_TRAITS(&& noexcept, )
65#endif
66
67#undef __NEFORCE_MEMFUNC_TRAITS_BASE
68#undef __NEFORCE_MEMFUNC_TRAITS
69
70
71template <typename Func, typename = void_t<>>
72struct maybe_get_result_type {};
73
74template <typename Func>
75struct maybe_get_result_type<Func, void_t<typename Func::result_type>> {
76 using result_type = typename Func::result_type;
77};
78
79
80template <typename Func>
81struct __weak_result_type_impl : maybe_get_result_type<Func> {};
82
83template <typename Res, typename... Args>
84struct __weak_result_type_impl<Res(Args...)> {
85 using result_type = Res;
86};
87template <typename Res, typename... Args>
88struct __weak_result_type_impl<Res(Args..., ...)> {
89 using result_type = Res;
90};
91template <typename Res, typename... Args>
92struct __weak_result_type_impl<Res (*)(Args...)> {
93 using result_type = Res;
94};
95template <typename Res, typename... Args>
96struct __weak_result_type_impl<Res (*)(Args..., ...)> {
97 using result_type = Res;
98};
99
100#ifdef NEFORCE_STANDARD_17
101template <typename Res, typename... Args>
102struct __weak_result_type_impl<Res(Args...) noexcept> {
103 using result_type = Res;
104};
105template <typename Res, typename... Args>
106struct __weak_result_type_impl<Res(Args..., ...) noexcept> {
107 using result_type = Res;
108};
109template <typename Res, typename... Args>
110struct __weak_result_type_impl<Res (*)(Args...) noexcept> {
111 using result_type = Res;
112};
113template <typename Res, typename... Args>
114struct __weak_result_type_impl<Res (*)(Args..., ...) noexcept> {
115 using result_type = Res;
116};
117#endif
118
119
120template <typename Func, bool = is_member_function_pointer<Func>::value>
121struct __weak_result_type_memfun : __weak_result_type_impl<Func> {};
122
123template <typename MemFunPtr>
124struct __weak_result_type_memfun<MemFunPtr, true> {
125 using result_type = typename mem_func_traits<MemFunPtr>::result_type;
126};
127
128template <typename Func, typename Class>
129struct __weak_result_type_memfun<Func Class::*, false> {};
130
138template <typename Func>
139struct weak_result_type : __weak_result_type_memfun<remove_cv_t<Func>> {};
140
141
148template <typename MemberPtr, bool IsMemFunc = is_member_function_pointer_v<MemberPtr>>
149class mem_func_base : public inner::mem_func_traits<MemberPtr>::maybe_type {
150 using Traits = inner::mem_func_traits<MemberPtr>;
151 using Arity = typename Traits::arity;
152 using Varargs = typename Traits::vararg;
153
154 template <typename Func, typename... BoundArgs>
155 friend struct bind_check_arity;
156
157 MemberPtr ptr_;
158
159public:
160 using result_type = typename Traits::result_type;
161
166 explicit constexpr mem_func_base(MemberPtr pmf) noexcept :
167 ptr_(pmf) {}
168
175 template <typename... Args>
176 NEFORCE_CONSTEXPR20 auto operator()(Args&&... args) const
177 noexcept(noexcept(_NEFORCE invoke(ptr_, _NEFORCE forward<Args>(args)...)))
178 -> decltype(_NEFORCE invoke(ptr_, _NEFORCE forward<Args>(args)...)) {
179 return _NEFORCE invoke(ptr_, _NEFORCE forward<Args>(args)...);
180 }
181};
182
186template <typename MemberObjPtr>
187class mem_func_base<MemberObjPtr, false> {
188 using Arity = integral_constant<size_t, 0>;
189 using Varargs = false_type;
190
191 template <typename Func, typename... BoundArgs>
192 friend struct bind_check_arity;
193
194 MemberObjPtr ptr_;
195
196public:
201 explicit constexpr mem_func_base(MemberObjPtr pm) noexcept :
202 ptr_(pm) {}
203
210 template <typename T>
211 NEFORCE_CONSTEXPR20 auto operator()(T&& obj) const
212 noexcept(noexcept(_NEFORCE invoke(ptr_, _NEFORCE forward<T>(obj))))
213 -> decltype(_NEFORCE invoke(ptr_, _NEFORCE forward<T>(obj))) {
214 return _NEFORCE invoke(ptr_, _NEFORCE forward<T>(obj));
215 }
216};
217
218template <typename MemberPointer>
219struct mem_func;
220
221template <typename Res, typename Class>
222struct mem_func<Res Class::*> : mem_func_base<Res Class::*> {
223 using mem_func_base<Res Class::*>::mem_func_base;
224};
225
226NEFORCE_END_INNER__
228
229
235
241template <typename T>
243
248template <typename T>
249NEFORCE_INLINE17 constexpr bool is_bind_expression_v = is_bind_expression<T>::value;
250
251
257template <uint32_t Num>
259
264template <uint32_t Num>
265NEFORCE_INLINE17 constexpr uint32_t placeholder_v = placeholder<Num>::value;
266
267
273template <typename T>
275
276template <uint32_t Num>
277struct is_placeholder<placeholder<Num>> : true_type {};
278
283template <typename T>
284NEFORCE_INLINE17 constexpr bool is_placeholder_v = is_placeholder<T>::value;
285
292namespace placeholders {
293 NEFORCE_INLINE17 constexpr placeholder<1> p1{};
294 NEFORCE_INLINE17 constexpr placeholder<2> p2{};
295 NEFORCE_INLINE17 constexpr placeholder<3> p3{};
296 NEFORCE_INLINE17 constexpr placeholder<4> p4{};
297 NEFORCE_INLINE17 constexpr placeholder<5> p5{};
298 NEFORCE_INLINE17 constexpr placeholder<6> p6{};
299 NEFORCE_INLINE17 constexpr placeholder<7> p7{};
300 NEFORCE_INLINE17 constexpr placeholder<8> p8{};
301 NEFORCE_INLINE17 constexpr placeholder<9> p9{};
302 NEFORCE_INLINE17 constexpr placeholder<10> p10{};
303 NEFORCE_INLINE17 constexpr placeholder<11> p11{};
304 NEFORCE_INLINE17 constexpr placeholder<12> p12{};
305 NEFORCE_INLINE17 constexpr placeholder<13> p13{};
306 NEFORCE_INLINE17 constexpr placeholder<14> p14{};
307 NEFORCE_INLINE17 constexpr placeholder<15> p15{};
308 NEFORCE_INLINE17 constexpr placeholder<16> p16{};
309 NEFORCE_INLINE17 constexpr placeholder<17> p17{};
310 NEFORCE_INLINE17 constexpr placeholder<18> p18{};
311 NEFORCE_INLINE17 constexpr placeholder<19> p19{};
312 NEFORCE_INLINE17 constexpr placeholder<20> p20{};
313 NEFORCE_INLINE17 constexpr placeholder<21> p21{};
314 NEFORCE_INLINE17 constexpr placeholder<22> p22{};
315 NEFORCE_INLINE17 constexpr placeholder<23> p23{};
316 NEFORCE_INLINE17 constexpr placeholder<24> p24{};
317 NEFORCE_INLINE17 constexpr placeholder<25> p25{};
318 NEFORCE_INLINE17 constexpr placeholder<26> p26{};
319 NEFORCE_INLINE17 constexpr placeholder<27> p27{};
320 NEFORCE_INLINE17 constexpr placeholder<28> p28{};
321 NEFORCE_INLINE17 constexpr placeholder<29> p29{};
322} // namespace placeholders
323
324
326NEFORCE_BEGIN_INNER__
327
341template <typename Arg, bool IsBindExp = is_bind_expression_v<Arg>, bool IsPlaceholder = is_placeholder_v<Arg>>
342class bind_arg_mapper;
343
344template <typename T>
345class bind_arg_mapper<reference_wrapper<T>, false, false> {
346public:
347 template <typename CVRef, typename Tuple>
348 NEFORCE_CONSTEXPR20 T& operator()(CVRef& arg, Tuple&) const volatile {
349 return arg.get();
350 }
351};
352
353template <typename Arg>
354class bind_arg_mapper<Arg, true, false> {
355public:
356 template <typename CVArg, typename... Args>
357 NEFORCE_CONSTEXPR20 auto operator()(CVArg& arg, tuple<Args...>& tuple_ref) const volatile
358 -> decltype(arg(declval<Args>()...)) {
359 using Indexes = build_index_tuple_t<sizeof...(Args)>;
360 return call(arg, tuple_ref, Indexes());
361 }
362
363private:
364 template <typename CVArg, typename... Args, size_t... Indexes>
365 NEFORCE_CONSTEXPR20 auto call(CVArg& arg, tuple<Args...>& tuple_ref, const index_tuple<Indexes...>&) const volatile
366 -> decltype(arg(declval<Args>()...)) {
367 return arg(_NEFORCE get<Indexes>(_NEFORCE move(tuple_ref))...);
368 }
369};
370
371
372template <typename Arg>
373class bind_arg_mapper<Arg, false, true> {
374 template <size_t I, typename Tuple>
375 using safe_tuple_element_t = enable_if_t<(I < tuple_size_v<Tuple>), tuple_element_t<I, Tuple>>;
376
377public:
378 template <typename Tuple>
379 NEFORCE_CONSTEXPR20 safe_tuple_element_t<(is_placeholder_v<Arg> - 1), Tuple>&& operator()(const volatile Arg&,
380 Tuple& tuple_ref) const
381 volatile {
382 return _NEFORCE get<(is_placeholder<Arg>::value - 1)>(_NEFORCE move(tuple_ref));
383 }
384};
385
386template <typename Arg>
387class bind_arg_mapper<Arg, false, false> {
388public:
389 template <typename CVArg, typename Tuple>
390 NEFORCE_CONSTEXPR20 CVArg&& operator()(CVArg&& arg, Tuple&) const volatile {
391 return _NEFORCE forward<CVArg>(arg);
392 }
393};
394
395NEFORCE_END_INNER__
397 // BindTraits
399
405
414template <typename Sign>
415class binder;
416
425template <typename Func, typename... BoundArgs>
426class binder<Func(BoundArgs...)> : public inner::weak_result_type<Func> {
427private:
428 using BoundIndexes = build_index_tuple_t<sizeof...(BoundArgs)>;
429
430 Func functor_;
431 tuple<BoundArgs...> bound_args_;
432
433private:
440 template <typename BoundArg, typename CallArgs>
441 struct arg_mapper_result {
442 using type = decltype(inner::bind_arg_mapper<remove_cv_t<BoundArg>>()(_NEFORCE declval<BoundArg&>(),
443 _NEFORCE declval<CallArgs&>()));
444 };
445
450 template <typename BoundArg, typename CallArgs>
451 using arg_mapper_result_t = typename arg_mapper_result<BoundArg, CallArgs>::type;
452
458 template <typename CallArgs>
460
466 template <typename CallArgs>
468
475 template <typename BoundArg, typename CallArgs>
476 using arg_mapper_type = decltype(inner::bind_arg_mapper<remove_cv_t<BoundArg>>()(_NEFORCE declval<BoundArg&>(),
477 _NEFORCE declval<CallArgs&>()));
478
484 template <typename CallArgs>
485 using dependent = enable_if_t<static_cast<bool>(tuple_size_v<CallArgs> + 1), Func>;
486
487private:
497 template <typename Res, typename... Args, size_t... Indexes>
498 NEFORCE_CONSTEXPR20 Res call(tuple<Args...>&& args, index_tuple<Indexes...> idx) {
499 return _NEFORCE invoke(functor_,
500 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
501 }
502
512 template <typename Res, typename... Args, _NEFORCE size_t... Indexes>
513 NEFORCE_CONSTEXPR20 Res call_const(tuple<Args...>&& args, index_tuple<Indexes...> idx) const {
514 return _NEFORCE invoke(functor_,
515 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
516 }
517
518public:
525 template <typename... Args>
526 explicit NEFORCE_CONSTEXPR20 binder(Func&& func, Args&&... args) :
527 functor_(_NEFORCE forward<Func>(func)),
528 bound_args_(_NEFORCE forward<Args>(args)...) {}
529
530 binder(const binder&) = default;
531 binder(binder&&) = default;
532
539 template <typename... Args>
540 NEFORCE_CONSTEXPR20 auto operator()(Args&&... args) -> result_type<tuple<Args&&...>> {
541 using Res = result_type<tuple<Args&&...>>;
542 return binder::call<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
543 }
544
551 template <typename... Args>
552 NEFORCE_CONSTEXPR20 auto operator()(Args&&... args) const -> result_type_const<tuple<Args&&...>> {
553 using Res = result_type_const<tuple<Args&&...>>;
554 return binder::call_const<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
555 }
556
557 template <typename... Args>
558 void operator()(Args&&... args) const volatile = delete;
559};
560
561
570template <typename Res, typename Sign>
572
579template <typename Res, typename Func, typename... BoundArgs>
580class bindrer<Res, Func(BoundArgs...)> {
581private:
582 using BoundIndexes = build_index_tuple_t<sizeof...(BoundArgs)>;
583
584 Func functor_;
585 tuple<BoundArgs...> bound_args_;
586
587private:
597 template <typename Result, typename... Args, size_t... Indexes>
598 NEFORCE_CONSTEXPR20 Result call(tuple<Args...>&& args, index_tuple<Indexes...> idx) {
599 return _NEFORCE invoke_r<Res>(functor_,
600 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
601 }
602
612 template <typename Result, typename... Args, _NEFORCE size_t... Indexes>
613 NEFORCE_CONSTEXPR20 Result call(tuple<Args...>&& args, index_tuple<Indexes...> idx) const {
614 return _NEFORCE invoke_r<Res>(functor_,
615 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
616 }
617
618public:
619 using result_type = Res;
620
627 template <typename... Args>
628 explicit NEFORCE_CONSTEXPR20 bindrer(Func&& func, Args&&... args) :
629 functor_(_NEFORCE forward<Func>(func)),
630 bound_args_(_NEFORCE forward<Args>(args)...) {}
631
632 bindrer(const bindrer&) = default;
633 bindrer(bindrer&&) = default;
634
641 template <typename... Args>
642 NEFORCE_CONSTEXPR20 result_type operator()(Args&&... args) {
643 return bindrer::call<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
644 }
645
652 template <typename... Args>
653 NEFORCE_CONSTEXPR20 result_type operator()(Args&&... args) const {
654 return bindrer::call<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
655 }
656
657 template <typename... Args>
658 void operator()(Args&&... args) const volatile = delete;
659};
660
661
663
664template <typename Sign>
665struct is_bind_expression<binder<Sign>> : true_type {};
666template <typename Res, typename Sign>
667struct is_bind_expression<bindrer<Res, Sign>> : true_type {};
668
669#define __NEFORCE_EXPAND_BIND_EXP(CV) \
670 template <typename Sign> \
671 struct is_bind_expression<CV binder<Sign>> : true_type {}; \
672 template <typename Res, typename Sign> \
673 struct is_bind_expression<CV bindrer<Res, Sign>> : true_type {};
674
675NEFORCE_MACRO_RANGES_CV(__NEFORCE_EXPAND_BIND_EXP)
676#undef __NEFORCE_EXPAND_BIND_EXP
677
678NEFORCE_BEGIN_INNER__
679
688template <typename Func, typename... BoundArgs>
689struct bind_check_arity {};
690
691template <typename Ret, typename... Args, typename... BoundArgs>
692struct bind_check_arity<Ret (*)(Args...), BoundArgs...> {
693 static_assert(sizeof...(BoundArgs) == sizeof...(Args), "Wrong number of arguments for function");
694};
695
696template <typename Ret, typename... Args, typename... BoundArgs>
697struct bind_check_arity<Ret (*)(Args..., ...), BoundArgs...> {
698 static_assert(sizeof...(BoundArgs) >= sizeof...(Args), "Wrong number of arguments for function");
699};
700
701template <typename T, typename Class, typename... BoundArgs>
702struct bind_check_arity<T Class::*, BoundArgs...> {
703 using Arity = typename mem_func<T Class::*>::Arity;
704 using Varargs = typename mem_func<T Class::*>::Varargs;
705 static_assert(Varargs::value ? sizeof...(BoundArgs) >= Arity::value + 1 : sizeof...(BoundArgs) == Arity::value + 1,
706 "Wrong number of arguments for pointer-to-member");
707};
708
709NEFORCE_END_INNER__
711
719template <bool IntLike, typename Func, typename... BoundArgs>
720struct bind_helper : inner::bind_check_arity<decay_t<Func>, BoundArgs...> {
723};
724
725template <typename Func, typename... BoundArgs>
726struct bind_helper<true, Func, BoundArgs...> {};
727
732template <bool IntLike, typename Func, typename... BoundArgs>
733using bind_helper_t = typename bind_helper<IntLike, Func, BoundArgs...>::type;
734
735
746template <typename Func, typename... BoundArgs>
747NEFORCE_DEPRECATED_FOR("use lambda or bind_front instead of bind")
748NEFORCE_NODISCARD
749 constexpr bind_helper_t<is_integral_like_v<Func>, Func, BoundArgs...> bind(Func&& func, BoundArgs&&... args) {
750 return bind_helper_t<false, Func, BoundArgs...>(_NEFORCE forward<Func>(func), _NEFORCE forward<BoundArgs>(args)...);
751}
752
753
761template <typename Res, typename Func, typename... BoundArgs>
762struct bindr_helper : inner::bind_check_arity<decay_t<Func>, BoundArgs...> {
764};
765
770template <typename Res, typename Func, typename... BoundArgs>
771using bindr_helper_t = typename bindr_helper<Res, Func, BoundArgs...>::type;
772
773
785template <typename Res, typename Func, typename... BoundArgs>
786NEFORCE_DEPRECATED_FOR("use lambda or bind_front instead of bind")
787NEFORCE_NODISCARD constexpr bindr_helper_t<Res, Func, BoundArgs...> bind(Func&& func, BoundArgs&&... args) {
788 return bindr_helper_t<Res, Func, BoundArgs...>(_NEFORCE forward<Func>(func), _NEFORCE forward<BoundArgs>(args)...);
789}
790
791
800template <typename Func, typename... BoundArgs>
802 static_assert(is_move_constructible<Func>::value, "Func should be move constructible");
803#ifdef NEFORCE_STANDARD_17
804 static_assert((is_move_constructible_v<BoundArgs> && ...), "Args should be move constructible");
805#endif
806
807private:
808 using BoundIndices = index_sequence_for<BoundArgs...>;
809
810 Func func_;
811 tuple<BoundArgs...> bound_args_;
812
813private:
824 template <typename T, size_t... Indices, typename... CallArgs>
825 static constexpr decltype(auto) call(T&& bind_object, index_sequence<Indices...> idx, CallArgs&&... call_args) {
826 return _NEFORCE invoke(_NEFORCE forward<T>(bind_object).func_,
827 _NEFORCE get<Indices>(_NEFORCE forward<T>(bind_object).bound_args_)...,
828 _NEFORCE forward<CallArgs>(call_args)...);
829 }
830
831public:
840 template <typename Fn, typename... Args>
841 explicit constexpr binder_front(int p, Fn&& func, Args&&... args) noexcept(
843 func_(_NEFORCE forward<Fn>(func)),
844 bound_args_(_NEFORCE forward<Args>(args)...) {
845 static_assert(sizeof...(Args) == sizeof...(BoundArgs), "Wrong number of arguments");
846 }
847
848 binder_front(const binder_front&) = default;
852
853 ~binder_front() = default;
854
861 template <typename... CallArgs>
862 constexpr invoke_result_t<Func&, BoundArgs&..., CallArgs...>
863 operator()(CallArgs&&... call_args) & noexcept(is_nothrow_invocable_v<Func&, BoundArgs&..., CallArgs...>) {
864 return binder_front::call(*this, BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
865 }
866
873 template <typename... CallArgs>
874 constexpr invoke_result_t<const Func&, const BoundArgs&..., CallArgs...> operator()(CallArgs&&... call_args)
875 const& noexcept(is_nothrow_invocable_v<const Func&, const BoundArgs&..., CallArgs...>) {
876 return binder_front::call(*this, BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
877 }
878
885 template <typename... CallArgs>
886 constexpr invoke_result_t<Func, BoundArgs..., CallArgs...>
887 operator()(CallArgs&&... call_args) && noexcept(is_nothrow_invocable_v<Func, BoundArgs..., CallArgs...>) {
888 return binder_front::call(_NEFORCE move(*this), BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
889 }
890
897 template <typename... CallArgs>
898 constexpr invoke_result_t<const Func, const BoundArgs..., CallArgs...> operator()(CallArgs&&... call_args)
899 const&& noexcept(is_nothrow_invocable_v<const Func, const BoundArgs..., CallArgs...>) {
900 return binder_front::call(_NEFORCE move(*this), BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
901 }
902};
903
910template <typename Func, typename... Args>
912
923template <typename Func, typename... Args>
924NEFORCE_NODISCARD constexpr binder_front_type<Func, Args...> bind_front(Func&& func, Args&&... args) noexcept(
925 is_nothrow_constructible<binder_front_type<Func, Args...>, int, Func, Args...>::value) {
926 return binder_front_type<Func, Args...>(0, _NEFORCE forward<Func>(func), _NEFORCE forward<Args>(args)...);
927}
928 // FunctionBinders
930
931NEFORCE_END_NAMESPACE__
932#endif // NEFORCE_CORE_FUNCTIONAL_BIND_HPP__
NEFORCE_CONSTEXPR20 auto operator()(Args &&... args) const -> result_type_const< tuple< Args &&... > >
const调用操作符
NEFORCE_CONSTEXPR20 binder(Func &&func, Args &&... args)
构造函数
binder(const binder &)=default
复制构造函数
NEFORCE_CONSTEXPR20 auto operator()(Args &&... args) -> result_type< tuple< Args &&... > >
调用操作符
binder(binder &&)=default
移动构造函数
通用函数绑定器
NEFORCE_CONSTEXPR20 bindrer(Func &&func, Args &&... args)
构造函数
Res result_type
指定的返回类型
bindrer(bindrer &&)=default
移动构造函数
bindrer(const bindrer &)=default
复制构造函数
NEFORCE_CONSTEXPR20 result_type operator()(Args &&... args)
调用操作符
NEFORCE_CONSTEXPR20 result_type operator()(Args &&... args) const
const调用操作符
指定返回类型的函数绑定器
引用包装器类模板
NEFORCE_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
NEFORCE_ALWAYS_INLINE enable_if_t< is_void_v< T >, future_result_t< T > > get(future< T > &f)
通用future结果获取函数
NEFORCE_INLINE17 constexpr bool is_integral_like_v
is_integral_like的便捷变量模板
NEFORCE_INLINE17 constexpr uint32_t placeholder_v
placeholder值的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_placeholder_v
is_placeholder的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_bind_expression_v
is_bind_expression的便捷变量模板
unsigned int uint32_t
32位无符号整数类型
add_rvalue_reference_t< T > declval() noexcept
获取类型的右值引用,仅用于非求值上下文
typename bindr_helper< Res, Func, BoundArgs... >::type bindr_helper_t
bindr_helper的便捷别名
binder_front< decay_t< Func >, decay_t< Args >... > binder_front_type
binder_front类型的便捷别名
typename bind_helper< IntLike, Func, BoundArgs... >::type bind_helper_t
bind_helper的便捷别名
NEFORCE_DEPRECATED_FOR("use lambda or bind_front instead of bind") NEFORCE_NODISCARD const expr bind_helper_t< is_integral_like_v< Func >
bind函数
NEFORCE_NODISCARD constexpr binder_front_type< Func, Args... > bind_front(Func &&func, Args &&... args) noexcept(is_nothrow_constructible< binder_front_type< Func, Args... >, int, Func, Args... >::value)
bind_front函数
typename build_index_tuple< Num >::type build_index_tuple_t
build_index_tuple的便捷别名
integer_sequence< size_t, Values... > index_sequence
索引序列
make_index_sequence< sizeof...(Types)> index_sequence_for
根据类型参数包生成索引序列
NEFORCE_INLINE17 constexpr bool is_nothrow_invocable_v
is_nothrow_invocable的便捷变量模板
NEFORCE_CONSTEXPR14 enable_if_t< is_invocable_r< Res, Callable, Args... >::value, Res > invoke_r(Callable &&f, Args &&... args) noexcept(is_nothrow_invocable< Callable, Args... >::value)
带返回类型检查的统一调用接口
NEFORCE_CONSTEXPR14 inner::__invoke_result_aux< Callable, Args... >::type invoke(Callable &&f, Args &&... args) noexcept(is_nothrow_invocable< Callable, Args... >::value)
统一调用接口
typename inner::__invoke_result_aux< F, Args... >::type invoke_result_t
invoke_result的便捷别名
uint64_t size_t
无符号大小类型
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
constexpr size_t tuple_size_v
tuple_size的类型别名
NEFORCE_NODISCARD constexpr tuple< Types &&... > forward_as_tuple(Types &&... args) noexcept
创建转发引用元组
typename tuple_element< Index, Types... >::type tuple_element_t
tuple_element的类型别名
typename decay< T >::type decay_t
decay的便捷别名
#define NEFORCE_MACRO_RANGES_CV(MAC)
cv限定符列表宏
NEFORCE_INLINE17 constexpr bool is_move_constructible_v
is_move_constructible的便捷变量模板
integral_constant< uint32_t, Value > uint32_constant
32位无符号整数常量包装器
bool_constant< true > true_type
表示true的类型
void void_t
将任意类型映射为void
bool_constant< false > false_type
表示false的类型
typename enable_if< Test, T >::type enable_if_t
enable_if的便捷别名
统一调用接口
占位符预定义实例命名空间
NEFORCE_INLINE17 constexpr placeholder< 27 > p27
占位符27
NEFORCE_INLINE17 constexpr placeholder< 16 > p16
占位符16
NEFORCE_INLINE17 constexpr placeholder< 9 > p9
占位符9
NEFORCE_INLINE17 constexpr placeholder< 6 > p6
占位符6
NEFORCE_INLINE17 constexpr placeholder< 25 > p25
占位符25
NEFORCE_INLINE17 constexpr placeholder< 19 > p19
占位符19
NEFORCE_INLINE17 constexpr placeholder< 3 > p3
占位符3
NEFORCE_INLINE17 constexpr placeholder< 4 > p4
占位符4
NEFORCE_INLINE17 constexpr placeholder< 5 > p5
占位符5
NEFORCE_INLINE17 constexpr placeholder< 20 > p20
占位符20
NEFORCE_INLINE17 constexpr placeholder< 21 > p21
占位符21
NEFORCE_INLINE17 constexpr placeholder< 29 > p29
占位符29
NEFORCE_INLINE17 constexpr placeholder< 7 > p7
占位符7
NEFORCE_INLINE17 constexpr placeholder< 24 > p24
占位符24
NEFORCE_INLINE17 constexpr placeholder< 28 > p28
占位符28
NEFORCE_INLINE17 constexpr placeholder< 18 > p18
占位符18
NEFORCE_INLINE17 constexpr placeholder< 23 > p23
占位符23
NEFORCE_INLINE17 constexpr placeholder< 1 > p1
占位符1
NEFORCE_INLINE17 constexpr placeholder< 11 > p11
占位符11
NEFORCE_INLINE17 constexpr placeholder< 12 > p12
占位符12
NEFORCE_INLINE17 constexpr placeholder< 26 > p26
占位符26
NEFORCE_INLINE17 constexpr placeholder< 17 > p17
占位符17
NEFORCE_INLINE17 constexpr placeholder< 15 > p15
占位符15
NEFORCE_INLINE17 constexpr placeholder< 2 > p2
占位符2
NEFORCE_INLINE17 constexpr placeholder< 13 > p13
占位符13
NEFORCE_INLINE17 constexpr placeholder< 8 > p8
占位符8
NEFORCE_INLINE17 constexpr placeholder< 22 > p22
占位符22
NEFORCE_INLINE17 constexpr placeholder< 10 > p10
占位符10
NEFORCE_INLINE17 constexpr placeholder< 14 > p14
占位符14
二元函数适配器基类
bind辅助类型推导器
decay_t< Func > func_type
函数类型
binder< func_type(decay_t< BoundArgs >...)> type
推导出的binder类型
前向参数绑定器
binder_front(const binder_front &)=default
复制构造函数
binder_front(binder_front &&)=default
移动构造函数
binder_front & operator=(binder_front &&)=default
移动赋值运算符
constexpr invoke_result_t< const Func &, const BoundArgs &..., CallArgs... > operator()(CallArgs &&... call_args) const &noexcept(is_nothrow_invocable_v< const Func &, const BoundArgs &..., CallArgs... >)
const左值调用操作符
~binder_front()=default
析构函数
constexpr invoke_result_t< Func &, BoundArgs &..., CallArgs... > operator()(CallArgs &&... call_args) &noexcept(is_nothrow_invocable_v< Func &, BoundArgs &..., CallArgs... >)
左值调用操作符
constexpr binder_front(int p, Fn &&func, Args &&... args) noexcept(conjunction< is_nothrow_constructible< Func, Fn >, is_nothrow_constructible< BoundArgs, Args >... >::value)
构造函数
constexpr invoke_result_t< const Func, const BoundArgs..., CallArgs... > operator()(CallArgs &&... call_args) const &&noexcept(is_nothrow_invocable_v< const Func, const BoundArgs..., CallArgs... >)
const右值调用操作符
constexpr invoke_result_t< Func, BoundArgs..., CallArgs... > operator()(CallArgs &&... call_args) &&noexcept(is_nothrow_invocable_v< Func, BoundArgs..., CallArgs... >)
右值调用操作符
binder_front & operator=(const binder_front &)=default
复制赋值运算符
指定返回类型的bind辅助类型推导器
类型集合的逻辑与操作
索引元组容器
判断是否为绑定表达式
判断类型是否可以使用指定参数无异常构造
判断是否为占位符
占位符类型
一元函数适配器基类