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
15NEFORCE_BEGIN_NAMESPACE__
16
18NEFORCE_BEGIN_INNER__
19
20template <typename Res, typename... Args>
21struct unary_or_binary_function {};
22
23template <typename Res, typename T1>
24struct unary_or_binary_function<Res, T1> : _NEFORCE unary_function<T1, Res> {};
25
26template <typename Res, typename T1, typename T2>
27struct unary_or_binary_function<Res, T1, T2> : _NEFORCE binary_function<T1, T2, Res> {};
28
29
34template <typename Sign>
35struct mem_func_traits;
36
37template <typename Res, typename Class, typename... Args>
38struct mem_func_traits_base {
39 using result_type = Res;
40 using maybe_type = unary_or_binary_function<Res, Class*, Args...>;
41 using arity = integral_constant<size_t, sizeof...(Args)>;
42};
43
44#define __NEFORCE_MEMFUNC_TRAITS_BASE(CV, REF) \
45 template <typename Res, typename Class, typename... Args> \
46 struct mem_func_traits<Res (Class::*)(Args...) CV REF> : mem_func_traits_base<Res, CV Class, Args...> { \
47 using vararg = false_type; \
48 }; \
49 template <typename Res, typename Class, typename... Args> \
50 struct mem_func_traits<Res (Class::*)(Args..., ...) CV REF> : mem_func_traits_base<Res, CV Class, Args...> { \
51 using vararg = true_type; \
52 };
53
54#define __NEFORCE_MEMFUNC_TRAITS(REF, P) \
55 __NEFORCE_MEMFUNC_TRAITS_BASE(, REF) \
56 __NEFORCE_MEMFUNC_TRAITS_BASE(const, REF) \
57 __NEFORCE_MEMFUNC_TRAITS_BASE(volatile, REF) \
58 __NEFORCE_MEMFUNC_TRAITS_BASE(const volatile, REF)
59
60__NEFORCE_MEMFUNC_TRAITS(, )
61__NEFORCE_MEMFUNC_TRAITS(&, )
62__NEFORCE_MEMFUNC_TRAITS(&&, )
63
64#ifdef NEFORCE_STANDARD_17
65__NEFORCE_MEMFUNC_TRAITS(noexcept, )
66__NEFORCE_MEMFUNC_TRAITS(& noexcept, )
67__NEFORCE_MEMFUNC_TRAITS(&& noexcept, )
68#endif
69
70#undef __NEFORCE_MEMFUNC_TRAITS_BASE
71#undef __NEFORCE_MEMFUNC_TRAITS
72
73
74template <typename Func, typename = void_t<>>
75struct maybe_get_result_type {};
76
77template <typename Func>
78struct maybe_get_result_type<Func, void_t<typename Func::result_type>> {
79 using result_type = typename Func::result_type;
80};
81
82
83template <typename Func>
84struct __weak_result_type_impl : maybe_get_result_type<Func> {};
85
86template <typename Res, typename... Args>
87struct __weak_result_type_impl<Res(Args...)> {
88 using result_type = Res;
89};
90template <typename Res, typename... Args>
91struct __weak_result_type_impl<Res(Args..., ...)> {
92 using result_type = Res;
93};
94template <typename Res, typename... Args>
95struct __weak_result_type_impl<Res (*)(Args...)> {
96 using result_type = Res;
97};
98template <typename Res, typename... Args>
99struct __weak_result_type_impl<Res (*)(Args..., ...)> {
100 using result_type = Res;
101};
102
103#ifdef NEFORCE_STANDARD_17
104template <typename Res, typename... Args>
105struct __weak_result_type_impl<Res(Args...) noexcept> {
106 using result_type = Res;
107};
108template <typename Res, typename... Args>
109struct __weak_result_type_impl<Res(Args..., ...) noexcept> {
110 using result_type = Res;
111};
112template <typename Res, typename... Args>
113struct __weak_result_type_impl<Res (*)(Args...) noexcept> {
114 using result_type = Res;
115};
116template <typename Res, typename... Args>
117struct __weak_result_type_impl<Res (*)(Args..., ...) noexcept> {
118 using result_type = Res;
119};
120#endif
121
122
123template <typename Func, bool = is_member_function_pointer<Func>::value>
124struct __weak_result_type_memfun : __weak_result_type_impl<Func> {};
125
126template <typename MemFunPtr>
127struct __weak_result_type_memfun<MemFunPtr, true> {
128 using result_type = typename mem_func_traits<MemFunPtr>::result_type;
129};
130
131template <typename Func, typename Class>
132struct __weak_result_type_memfun<Func Class::*, false> {};
133
141template <typename Func>
142struct weak_result_type : __weak_result_type_memfun<remove_cv_t<Func>> {};
143
144
151template <typename MemberPtr, bool IsMemFunc = is_member_function_pointer_v<MemberPtr>>
152class mem_func_base : public inner::mem_func_traits<MemberPtr>::maybe_type {
153 using Traits = inner::mem_func_traits<MemberPtr>;
154 using Arity = typename Traits::arity;
155 using Varargs = typename Traits::vararg;
156
157 template <typename Func, typename... BoundArgs>
158 friend struct bind_check_arity;
159
160 MemberPtr ptr_;
161
162public:
163 using result_type = typename Traits::result_type;
164
169 explicit constexpr mem_func_base(MemberPtr pmf) noexcept :
170 ptr_(pmf) {}
171
178 template <typename... Args>
179 NEFORCE_CONSTEXPR20 auto operator()(Args&&... args) const
180 noexcept(noexcept(_NEFORCE invoke(ptr_, _NEFORCE forward<Args>(args)...)))
181 -> decltype(_NEFORCE invoke(ptr_, _NEFORCE forward<Args>(args)...)) {
182 return _NEFORCE invoke(ptr_, _NEFORCE forward<Args>(args)...);
183 }
184};
185
189template <typename MemberObjPtr>
190class mem_func_base<MemberObjPtr, false> {
191 using Arity = integral_constant<size_t, 0>;
192 using Varargs = false_type;
193
194 template <typename Func, typename... BoundArgs>
195 friend struct bind_check_arity;
196
197 MemberObjPtr ptr_;
198
199public:
204 explicit constexpr mem_func_base(MemberObjPtr pm) noexcept :
205 ptr_(pm) {}
206
213 template <typename T>
214 NEFORCE_CONSTEXPR20 auto operator()(T&& obj) const
215 noexcept(noexcept(_NEFORCE invoke(ptr_, _NEFORCE forward<T>(obj))))
216 -> decltype(_NEFORCE invoke(ptr_, _NEFORCE forward<T>(obj))) {
217 return _NEFORCE invoke(ptr_, _NEFORCE forward<T>(obj));
218 }
219};
220
221template <typename MemberPointer>
222struct mem_func;
223
224template <typename Res, typename Class>
225struct mem_func<Res Class::*> : mem_func_base<Res Class::*> {
226 using mem_func_base<Res Class::*>::mem_func_base;
227};
228
229NEFORCE_END_INNER__
231
232
238
244template <typename T>
246
251template <typename T>
252NEFORCE_INLINE17 constexpr bool is_bind_expression_v = is_bind_expression<T>::value;
253
254
260template <uint32_t Num>
262
263
269template <typename T>
271
272template <uint32_t Num>
273struct is_placeholder<placeholder<Num>> : uint32_constant<Num> {};
274
279template <typename T>
281
288namespace placeholders {
289 NEFORCE_INLINE17 constexpr placeholder<1> p1{};
290 NEFORCE_INLINE17 constexpr placeholder<2> p2{};
291 NEFORCE_INLINE17 constexpr placeholder<3> p3{};
292 NEFORCE_INLINE17 constexpr placeholder<4> p4{};
293 NEFORCE_INLINE17 constexpr placeholder<5> p5{};
294 NEFORCE_INLINE17 constexpr placeholder<6> p6{};
295 NEFORCE_INLINE17 constexpr placeholder<7> p7{};
296 NEFORCE_INLINE17 constexpr placeholder<8> p8{};
297 NEFORCE_INLINE17 constexpr placeholder<9> p9{};
298 NEFORCE_INLINE17 constexpr placeholder<10> p10{};
299 NEFORCE_INLINE17 constexpr placeholder<11> p11{};
300 NEFORCE_INLINE17 constexpr placeholder<12> p12{};
301 NEFORCE_INLINE17 constexpr placeholder<13> p13{};
302 NEFORCE_INLINE17 constexpr placeholder<14> p14{};
303 NEFORCE_INLINE17 constexpr placeholder<15> p15{};
304 NEFORCE_INLINE17 constexpr placeholder<16> p16{};
305 NEFORCE_INLINE17 constexpr placeholder<17> p17{};
306 NEFORCE_INLINE17 constexpr placeholder<18> p18{};
307 NEFORCE_INLINE17 constexpr placeholder<19> p19{};
308 NEFORCE_INLINE17 constexpr placeholder<20> p20{};
309 NEFORCE_INLINE17 constexpr placeholder<21> p21{};
310 NEFORCE_INLINE17 constexpr placeholder<22> p22{};
311 NEFORCE_INLINE17 constexpr placeholder<23> p23{};
312 NEFORCE_INLINE17 constexpr placeholder<24> p24{};
313 NEFORCE_INLINE17 constexpr placeholder<25> p25{};
314 NEFORCE_INLINE17 constexpr placeholder<26> p26{};
315 NEFORCE_INLINE17 constexpr placeholder<27> p27{};
316 NEFORCE_INLINE17 constexpr placeholder<28> p28{};
317 NEFORCE_INLINE17 constexpr placeholder<29> p29{};
318} // namespace placeholders
319
320
322NEFORCE_BEGIN_INNER__
323
337template <typename Arg, bool IsBindExp = is_bind_expression_v<Arg>, bool IsPlaceholder = is_placeholder_v<Arg> != 0>
338class bind_arg_mapper;
339
340template <typename T>
341class bind_arg_mapper<reference_wrapper<T>, false, false> {
342public:
343 template <typename CVRef, typename Tuple>
344 NEFORCE_CONSTEXPR20 T& operator()(CVRef& arg, Tuple& /*unused*/) const volatile {
345 return arg.get();
346 }
347};
348
349template <typename Arg>
350class bind_arg_mapper<Arg, true, false> {
351public:
352 template <typename CVArg, typename... Args>
353 NEFORCE_CONSTEXPR20 auto operator()(CVArg& arg, tuple<Args...>& tuple_ref) const volatile
354 -> decltype(arg(declval<Args>()...)) {
355 using Indexes = build_index_tuple_t<sizeof...(Args)>;
356 return call(arg, tuple_ref, Indexes());
357 }
358
359private:
360 template <typename CVArg, typename... Args, size_t... Indexes>
361 NEFORCE_CONSTEXPR20 auto call(CVArg& arg, tuple<Args...>& tuple_ref,
362 const index_tuple<Indexes...>& /*unused*/) const volatile
363 -> decltype(arg(declval<Args>()...)) {
364 return arg(_NEFORCE get<Indexes>(_NEFORCE move(tuple_ref))...);
365 }
366};
367
368
369template <typename Arg>
370class bind_arg_mapper<Arg, false, true> {
371 template <size_t I, typename Tuple>
372 using safe_tuple_element_t = enable_if_t<(I < tuple_size_v<Tuple>), tuple_element_t<I, Tuple>>;
373
374public:
375 template <typename Tuple>
376 NEFORCE_CONSTEXPR20 safe_tuple_element_t<(is_placeholder_v<Arg> - 1), Tuple>&&
377 operator()(const volatile Arg& /*unused*/, Tuple& tuple_ref) const volatile {
378 return _NEFORCE get<(is_placeholder_v<Arg> - 1)>(_NEFORCE move(tuple_ref));
379 }
380};
381
382template <typename Arg>
383class bind_arg_mapper<Arg, false, false> {
384public:
385 template <typename CVArg, typename Tuple>
386 NEFORCE_CONSTEXPR20 CVArg&& operator()(CVArg&& arg, Tuple& /*unused*/) const volatile {
387 return _NEFORCE forward<CVArg>(arg);
388 }
389};
390
391NEFORCE_END_INNER__
393 // BindTraits
395
401
410template <typename Sign>
411class binder;
412
421template <typename Func, typename... BoundArgs>
422class binder<Func(BoundArgs...)> : public inner::weak_result_type<Func> {
423private:
424 using BoundIndexes = build_index_tuple_t<sizeof...(BoundArgs)>;
425
426 Func functor_;
427 tuple<BoundArgs...> bound_args_;
428
429private:
436 template <typename BoundArg, typename CallArgs>
437 struct arg_mapper_result {
438 using type = decltype(inner::bind_arg_mapper<remove_cv_t<BoundArg>>()(_NEFORCE declval<BoundArg&>(),
439 _NEFORCE declval<CallArgs&>()));
440 };
441
446 template <typename BoundArg, typename CallArgs>
447 using arg_mapper_result_t = typename arg_mapper_result<BoundArg, CallArgs>::type;
448
454 template <typename CallArgs>
456
462 template <typename CallArgs>
464
471 template <typename BoundArg, typename CallArgs>
472 using arg_mapper_type = decltype(inner::bind_arg_mapper<remove_cv_t<BoundArg>>()(_NEFORCE declval<BoundArg&>(),
473 _NEFORCE declval<CallArgs&>()));
474
480 template <typename CallArgs>
481 using dependent = enable_if_t<static_cast<bool>(tuple_size_v<CallArgs> + 1), Func>;
482
483private:
493 template <typename Res, typename... Args, size_t... Indexes>
494 NEFORCE_CONSTEXPR20 Res call(tuple<Args...>&& args, index_tuple<Indexes...> idx) {
495 return _NEFORCE invoke(functor_,
496 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
497 }
498
508 template <typename Res, typename... Args, _NEFORCE size_t... Indexes>
509 NEFORCE_CONSTEXPR20 Res call_const(tuple<Args...>&& args, index_tuple<Indexes...> idx) const {
510 return _NEFORCE invoke(functor_,
511 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
512 }
513
514public:
521 template <typename... Args>
522 explicit NEFORCE_CONSTEXPR20 binder(Func func, Args&&... args) :
523 functor_(_NEFORCE forward<Func>(func)),
524 bound_args_(_NEFORCE forward<Args>(args)...) {}
525
526 binder(const binder&) = default;
527 binder(binder&&) = default;
528
535 template <typename... Args>
536 NEFORCE_CONSTEXPR20 decltype(auto) operator()(Args&&... args) {
537 using Res = result_type<tuple<Args&&...>>;
538 return binder::call<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
539 }
540
547 template <typename... Args>
548 NEFORCE_CONSTEXPR20 decltype(auto) operator()(Args&&... args) const {
549 using Res = result_type_const<tuple<Args&&...>>;
550 return binder::call_const<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
551 }
552
553 template <typename... Args>
554 void operator()(Args&&... args) const volatile = delete;
555};
556
557
566template <typename Res, typename Sign>
568
575template <typename Res, typename Func, typename... BoundArgs>
576class bindrer<Res, Func(BoundArgs...)> {
577private:
578 using BoundIndexes = build_index_tuple_t<sizeof...(BoundArgs)>;
579
580 Func functor_;
581 tuple<BoundArgs...> bound_args_;
582
583private:
593 template <typename Result, typename... Args, size_t... Indexes>
594 NEFORCE_CONSTEXPR20 Result call(tuple<Args...>&& args, index_tuple<Indexes...> idx) {
595 return _NEFORCE invoke_r<Res>(functor_,
596 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
597 }
598
608 template <typename Result, typename... Args, _NEFORCE size_t... Indexes>
609 NEFORCE_CONSTEXPR20 Result call(tuple<Args...>&& args, index_tuple<Indexes...> idx) const {
610 return _NEFORCE invoke_r<Res>(functor_,
611 inner::bind_arg_mapper<BoundArgs>()(_NEFORCE get<Indexes>(bound_args_), args)...);
612 }
613
614public:
615 using result_type = Res;
616
623 template <typename... Args>
624 explicit NEFORCE_CONSTEXPR20 bindrer(Func func, Args&&... args) :
625 functor_(_NEFORCE forward<Func>(func)),
626 bound_args_(_NEFORCE forward<Args>(args)...) {}
627
628 bindrer(const bindrer&) = default;
629 bindrer(bindrer&&) = default;
630
637 template <typename... Args>
638 NEFORCE_CONSTEXPR20 result_type operator()(Args&&... args) {
639 return bindrer::call<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
640 }
641
648 template <typename... Args>
649 NEFORCE_CONSTEXPR20 result_type operator()(Args&&... args) const {
650 return bindrer::call<Res>(_NEFORCE forward_as_tuple(_NEFORCE forward<Args>(args)...), BoundIndexes());
651 }
652
653 template <typename... Args>
654 void operator()(Args&&... args) const volatile = delete;
655};
656
657
659
660template <typename Sign>
661struct is_bind_expression<binder<Sign>> : true_type {};
662template <typename Res, typename Sign>
663struct is_bind_expression<bindrer<Res, Sign>> : true_type {};
664
665#define __NEFORCE_EXPAND_BIND_EXP(CV) \
666 template <typename Sign> \
667 struct is_bind_expression<CV binder<Sign>> : true_type {}; \
668 template <typename Res, typename Sign> \
669 struct is_bind_expression<CV bindrer<Res, Sign>> : true_type {};
670
671NEFORCE_MACRO_RANGES_CV(__NEFORCE_EXPAND_BIND_EXP)
672#undef __NEFORCE_EXPAND_BIND_EXP
673
674NEFORCE_BEGIN_INNER__
675
684template <typename Func, typename... BoundArgs>
685struct bind_check_arity {};
686
687template <typename Ret, typename... Args, typename... BoundArgs>
688struct bind_check_arity<Ret (*)(Args...), BoundArgs...> {
689 static_assert(sizeof...(BoundArgs) == sizeof...(Args), "Wrong number of arguments for function");
690};
691
692template <typename Ret, typename... Args, typename... BoundArgs>
693struct bind_check_arity<Ret (*)(Args..., ...), BoundArgs...> {
694 static_assert(sizeof...(BoundArgs) >= sizeof...(Args), "Wrong number of arguments for function");
695};
696
697template <typename T, typename Class, typename... BoundArgs>
698struct bind_check_arity<T Class::*, BoundArgs...> {
699 using Arity = typename mem_func<T Class::*>::Arity;
700 using Varargs = typename mem_func<T Class::*>::Varargs;
701 static_assert(Varargs::value ? sizeof...(BoundArgs) >= Arity::value + 1 : sizeof...(BoundArgs) == Arity::value + 1,
702 "Wrong number of arguments for pointer-to-member");
703};
704
705NEFORCE_END_INNER__
707
715template <bool IntLike, typename Func, typename... BoundArgs>
716struct bind_helper : inner::bind_check_arity<decay_t<Func>, BoundArgs...> {
719};
720
721template <typename Func, typename... BoundArgs>
722struct bind_helper<true, Func, BoundArgs...> {};
723
728template <bool IntLike, typename Func, typename... BoundArgs>
729using bind_helper_t = typename bind_helper<IntLike, Func, BoundArgs...>::type;
730
731
742template <typename Func, typename... BoundArgs>
743NEFORCE_DEPRECATED_FOR("use lambda or bind_front instead of bind")
744NEFORCE_NODISCARD
745 constexpr bind_helper_t<is_integral_like_v<Func>, Func, BoundArgs...> bind(Func&& func, BoundArgs&&... args) {
746 return bind_helper_t<false, Func, BoundArgs...>(_NEFORCE forward<Func>(func), _NEFORCE forward<BoundArgs>(args)...);
747}
748
749
757template <typename Res, typename Func, typename... BoundArgs>
758struct bindr_helper : inner::bind_check_arity<decay_t<Func>, BoundArgs...> {
760};
761
766template <typename Res, typename Func, typename... BoundArgs>
767using bindr_helper_t = typename bindr_helper<Res, Func, BoundArgs...>::type;
768
769
781template <typename Res, typename Func, typename... BoundArgs>
782NEFORCE_DEPRECATED_FOR("use lambda or bind_front instead of bind")
783NEFORCE_NODISCARD constexpr bindr_helper_t<Res, Func, BoundArgs...> bind(Func&& func, BoundArgs&&... args) {
784 return bindr_helper_t<Res, Func, BoundArgs...>(_NEFORCE forward<Func>(func), _NEFORCE forward<BoundArgs>(args)...);
785}
786
787
796template <typename Func, typename... BoundArgs>
798 static_assert(is_move_constructible<Func>::value, "Func should be move constructible");
799#ifdef NEFORCE_STANDARD_17
800 static_assert((is_move_constructible_v<BoundArgs> && ...), "Args should be move constructible");
801#endif
802
803private:
804 using BoundIndices = index_sequence_for<BoundArgs...>;
805
806 Func func_;
807 tuple<BoundArgs...> bound_args_;
808
809private:
810 template <size_t... Indices, typename... CallArgs>
811 constexpr decltype(auto) call_impl(index_sequence<Indices...> /*unused*/, CallArgs&&... call_args) & {
812 return _NEFORCE invoke(func_, _NEFORCE get<Indices>(bound_args_)..., _NEFORCE forward<CallArgs>(call_args)...);
813 }
814
815 template <size_t... Indices, typename... CallArgs>
816 constexpr decltype(auto) call_impl(index_sequence<Indices...> /*unused*/, CallArgs&&... call_args) const& {
817 return _NEFORCE invoke(func_, _NEFORCE get<Indices>(bound_args_)..., _NEFORCE forward<CallArgs>(call_args)...);
818 }
819
820 template <size_t... Indices, typename... CallArgs>
821 constexpr decltype(auto) call_impl(index_sequence<Indices...> /*unused*/, CallArgs&&... call_args) && {
822 return _NEFORCE invoke(_NEFORCE move(func_), _NEFORCE get<Indices>(_NEFORCE move(bound_args_))...,
823 _NEFORCE forward<CallArgs>(call_args)...);
824 }
825
826 template <size_t... Indices, typename... CallArgs>
827 constexpr decltype(auto) call_impl(index_sequence<Indices...> /*unused*/, CallArgs&&... call_args) const&& {
828 return _NEFORCE invoke(_NEFORCE move(func_), _NEFORCE get<Indices>(_NEFORCE move(bound_args_))...,
829 _NEFORCE forward<CallArgs>(call_args)...);
830 }
831
832public:
841 template <typename Fn, typename... Args>
842 constexpr binder_front(int p, Fn&& func, Args&&... args) noexcept(
844 func_(_NEFORCE forward<Fn>(func)),
845 bound_args_(_NEFORCE forward<Args>(args)...) {
846 static_assert(sizeof...(Args) == sizeof...(BoundArgs), "Wrong number of arguments");
847 }
848
849 binder_front(const binder_front&) = default;
853
854 ~binder_front() = default;
855
862 template <typename... CallArgs>
863 constexpr decltype(auto)
864 operator()(CallArgs&&... call_args) & noexcept(is_nothrow_invocable_v<Func&, BoundArgs&..., CallArgs...>) {
865 return call_impl(BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
866 }
867
874 template <typename... CallArgs>
875 constexpr decltype(auto) operator()(CallArgs&&... call_args) const& noexcept(
877 return call_impl(BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
878 }
879
886 template <typename... CallArgs>
887 constexpr decltype(auto)
888 operator()(CallArgs&&... call_args) && noexcept(is_nothrow_invocable_v<Func, BoundArgs..., CallArgs...>) {
889 return _NEFORCE move(*this).call_impl(BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
890 }
891
898 template <typename... CallArgs>
899 constexpr decltype(auto) operator()(CallArgs&&... call_args) const&& noexcept(
901 return _NEFORCE move(*this).call_impl(BoundIndices(), _NEFORCE forward<CallArgs>(call_args)...);
902 }
903};
904
911template <typename Func, typename... Args>
913
924template <typename Func, typename... Args>
925NEFORCE_NODISCARD constexpr binder_front_type<Func, Args...> bind_front(Func&& func, Args&&... args) noexcept(
926 is_nothrow_constructible<binder_front_type<Func, Args...>, int, Func, Args...>::value) {
927 return binder_front_type<Func, Args...>(0, _NEFORCE forward<Func>(func), _NEFORCE forward<Args>(args)...);
928}
929 // FunctionBinders
931
932NEFORCE_END_NAMESPACE__
933#endif // NEFORCE_CORE_FUNCTIONAL_BIND_HPP__
constexpr binder(Func func, Args &&... args)
构造函数
binder(const binder &)=default
复制构造函数
binder(binder &&)=default
移动构造函数
通用函数绑定器
Res result_type
指定的返回类型
constexpr result_type operator()(Args &&... args)
调用操作符
bindrer(bindrer &&)=default
移动构造函数
bindrer(const bindrer &)=default
复制构造函数
constexpr bindrer(Func func, Args &&... args)
构造函数
constexpr result_type operator()(Args &&... args) const
const调用操作符
指定返回类型的函数绑定器
引用包装器类模板
仿函数
constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
enable_if_t< is_void_v< T >, future_result_t< T > > get(future< T > &f)
通用future结果获取函数
constexpr bool is_integral_like_v
is_integral_like的便捷变量模板
constexpr uint32_t is_placeholder_v
is_placeholder的便捷变量模板
constexpr bool is_bind_expression_v
is_bind_expression的便捷变量模板
unsigned int uint32_t
32位无符号整数类型
add_rvalue_reference_t< T > declval() noexcept
获取类型的右值引用,仅用于非求值上下文
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函数
NEFORCE_DEPRECATED_FOR("use lambda or bind_front instead of bind") const expr bind_helper_t< is_integral_like_v< Func >
bind函数
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的便捷别名
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
根据类型参数包生成索引序列
constexpr inner::__invoke_result_aux< Callable, Args... >::type invoke(Callable &&f, Args &&... args) noexcept(is_nothrow_invocable< Callable, Args... >::value)
统一调用接口
constexpr enable_if_t< is_invocable_r< Res, Callable, Args... >::value, Res > invoke_r(Callable &&f, Args &&... args) noexcept(is_nothrow_invocable< Callable, Args... >::value)
带返回类型检查的统一调用接口
typename inner::__invoke_result_aux< F, Args... >::type invoke_result_t
invoke_result的便捷别名
constexpr bool is_nothrow_invocable_v
is_nothrow_invocable的便捷变量模板
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的类型别名
typename tuple_element< Index, Types... >::type tuple_element_t
tuple_element的类型别名
constexpr tuple< Types &&... > forward_as_tuple(Types &&... args) noexcept
创建转发引用元组
typename decay< T >::type decay_t
decay的便捷别名
#define NEFORCE_MACRO_RANGES_CV(MAC)
cv限定符列表宏
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的便捷别名
整数序列工具
统一调用接口
占位符预定义实例命名空间
constexpr placeholder< 15 > p15
占位符15
constexpr placeholder< 12 > p12
占位符12
constexpr placeholder< 27 > p27
占位符27
constexpr placeholder< 6 > p6
占位符6
constexpr placeholder< 1 > p1
占位符1
constexpr placeholder< 14 > p14
占位符14
constexpr placeholder< 3 > p3
占位符3
constexpr placeholder< 23 > p23
占位符23
constexpr placeholder< 22 > p22
占位符22
constexpr placeholder< 5 > p5
占位符5
constexpr placeholder< 8 > p8
占位符8
constexpr placeholder< 7 > p7
占位符7
constexpr placeholder< 2 > p2
占位符2
constexpr placeholder< 20 > p20
占位符20
constexpr placeholder< 21 > p21
占位符21
constexpr placeholder< 29 > p29
占位符29
constexpr placeholder< 25 > p25
占位符25
constexpr placeholder< 24 > p24
占位符24
constexpr placeholder< 28 > p28
占位符28
constexpr placeholder< 16 > p16
占位符16
constexpr placeholder< 10 > p10
占位符10
constexpr placeholder< 26 > p26
占位符26
constexpr placeholder< 19 > p19
占位符19
constexpr placeholder< 11 > p11
占位符11
constexpr placeholder< 18 > p18
占位符18
constexpr placeholder< 13 > p13
占位符13
constexpr placeholder< 17 > p17
占位符17
constexpr placeholder< 4 > p4
占位符4
constexpr placeholder< 9 > p9
占位符9
二元函数适配器基类
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
移动赋值运算符
~binder_front()=default
析构函数
constexpr binder_front(int p, Fn &&func, Args &&... args) noexcept(conjunction< is_nothrow_constructible< Func, Fn >, is_nothrow_constructible< BoundArgs, Args >... >::value)
构造函数
binder_front & operator=(const binder_front &)=default
复制赋值运算符
指定返回类型的bind辅助类型推导器
类型集合的逻辑与操作
索引元组容器
判断是否为绑定表达式
判断类型是否可以使用指定参数无异常构造
判断是否为占位符
占位符类型
一元函数适配器基类
元组实现