YSTest: functional.hpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

functional.hpp
浏览该文件的文档.
1 /*
2 © 2010-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_ystdex_functional_hpp_
29 #define YB_INC_ystdex_functional_hpp_ 1
30
31 #include "type_op.hpp" // for "tuple.hpp", true_type, std::tuple,
32 // is_convertible, vseq::at, bool_constant, index_sequence_for,
33 // member_target_type_t, _t, std::tuple_size, vseq::join_n_t, std::swap,
34 // common_nonvoid_t, false_type, integral_constant, is_nothrow_swappable,
35 // make_index_sequence, exclude_self_t;
36 #include "functor.hpp" // for "ref.hpp", <functional>, std::function,
37 // __cpp_lib_invoke, less, addressof_op, mem_get;
38 #include <numeric> // for std::accumulate;
39
40 namespace ystdex
41 {
42
44
45 namespace details
46 {
47
48 template<class, class, class>
49 struct tuple_element_convertible;
50
51 template<class _type1, class _type2>
52 struct tuple_element_convertible<_type1, _type2, index_sequence<>>
53 : true_type
54 {};
55
56 template<typename... _types1, typename... _types2, size_t... _vSeq,
57 size_t _vHead>
58 struct tuple_element_convertible<std::tuple<_types1...>, std::tuple<_types2...>,
59 index_sequence<_vHead, _vSeq...>>
60 {
61 static_assert(sizeof...(_types1) == sizeof...(_types2),
62 "Mismatched sizes of tuple found.");
63
64 private:
65 using t1 = std::tuple<_types1...>;
66 using t2 = std::tuple<_types2...>;
67
68 public:
69 static yconstexpr const bool value
70 = is_convertible<vseq::at<t1, _vHead>, vseq::at<t2, _vHead>>::value
71 && tuple_element_convertible<t1, t2, index_sequence<_vSeq...>>::value;
72 };
73
74 } // namespace details;
75
81
83 template<typename _tFrom, typename _tTo>
84 struct is_covariant : is_convertible<_tFrom, _tTo>
85 {};
86
87 template<typename _tFrom, typename _tTo, typename... _tFromParams,
88 typename... _tToParams>
89 struct is_covariant<_tFrom(_tFromParams...), _tTo(_tToParams...)>
90 : is_covariant<_tFrom, _tTo>
91 {};
92
93 template<typename... _tFroms, typename... _tTos>
94 struct is_covariant<std::tuple<_tFroms...>, std::tuple<_tTos...>>
95 : bool_constant<details::tuple_element_convertible<std::tuple<_tFroms...>,
96 std::tuple<_tTos...>, index_sequence_for<_tTos...>>::value>
97 {};
98
100 template<typename _tFrom, typename _tTo, typename... _tFromParams,
101 typename... _tToParams>
102 struct is_covariant<std::function<_tFrom(_tFromParams...)>,
103 std::function<_tTo(_tToParams...)>>
104 : is_covariant<_tFrom(_tFromParams...), _tTo(_tToParams...)>
105 {};
107
108
110
111 template<typename _tFrom, typename _tTo>
112 struct is_contravariant : is_convertible<_tTo, _tFrom>
113 {};
114
115 template<typename _tResFrom, typename _tResTo, typename... _tFromParams,
116 typename... _tToParams>
117 struct is_contravariant<_tResFrom(_tFromParams...), _tResTo(_tToParams...)>
118 : is_contravariant<std::tuple<_tFromParams...>, std::tuple<_tToParams...>>
119 {};
120
121 template<typename... _tFroms, typename... _tTos>
122 struct is_contravariant<std::tuple<_tFroms...>, std::tuple<_tTos...>>
123 : bool_constant<details::tuple_element_convertible<std::tuple<_tTos...>,
124 std::tuple<_tFroms...>, index_sequence_for<_tTos...>>::value>
125 {};
126
128 template<typename _tResFrom, typename _tResTo, typename... _tFromParams,
129 typename... _tToParams>
130 struct is_contravariant<std::function<_tResFrom(_tFromParams...)>,
131 std::function<_tResTo(_tToParams...)>>
132 : is_contravariant<_tResFrom(_tFromParams...), _tResTo(_tToParams...)>
133 {};
135
136
137
139
140 template<typename... _tParams>
142 yconstfn size_t
143 sizeof_params(_tParams&&...) ynothrow
144 {
145 return sizeof...(_tParams);
146 }
147
148
150
151
153 template<size_t _vN>
154 struct variadic_param
155 {
157 template<typename _type, typename... _tParams>
158 static yconstfn auto
159 get(_type&&, _tParams&&... args) ynothrow
160 -> decltype(variadic_param<_vN - 1>::get(yforward(args)...))
161 {
162 static_assert(sizeof...(args) == _vN,
163 "Wrong variadic arguments number found.");
164
165 return variadic_param<_vN - 1>::get(yforward(args)...);
166 }
167 };
168
169 template<>
170 struct variadic_param<0U>
171 {
173 template<typename _type>
174 static yconstfn auto
175 get(_type&& arg) ynothrow -> decltype(yforward(arg))
176 {
177 return yforward(arg);
178 }
179 };
181
182
187 template<size_t _vN, typename... _tParams>
188 yconstfn auto
189 varg(_tParams&&... args) ynothrow
190 -> decltype(variadic_param<_vN>::get(yforward(args)...))
191 {
192 static_assert(_vN < sizeof...(args),
193 "Out-of-range index of variadic argument found.");
194
195 return variadic_param<_vN>::get(yforward(args)...);
196 }
198
199
201
202
204 template<typename _func>
205 inline void
206 chain_apply(_func&& f) ynothrow
207 {
208 return yforward(f);
209 }
210 template<typename _func, typename _type, typename... _tParams>
211 inline void
212 chain_apply(_func&& f, _type&& arg, _tParams&&... args)
213 ynoexcept_spec(ystdex::chain_apply(
214 yforward(yforward(f)(yforward(arg))), yforward(args)...))
215 {
216 return ystdex::chain_apply(yforward(yforward(f)(yforward(arg))),
217 yforward(args)...);
218 }
220
222
223 template<typename _func>
224 inline void
225 seq_apply(_func&&) ynothrow
226 {}
228 template<typename _func, typename _type, typename... _tParams>
229 inline void
230 seq_apply(_func&& f, _type&& arg, _tParams&&... args)
231 ynoexcept_spec(yimpl(yunseq(0, (void(yforward(f)(yforward(args))), 0)...)))
232 {
233 yforward(f)(yforward(arg));
234 ystdex::seq_apply(yforward(f), yforward(args)...);
235 }
237
239 template<typename _func, typename... _tParams>
240 inline void
241 unseq_apply(_func&& f, _tParams&&... args)
242 ynoexcept_spec(yimpl(yunseq((void(yforward(f)(yforward(args))), 0)...)))
243 {
244 yunseq((void(yforward(f)(yforward(args))), 0)...);
245 }
247
248
249 // TODO: Blocked. Wait for upcoming ISO C++17 for %__cplusplus.
250 #if __cpp_lib_invoke >= 201411
251 using std::invoke;
253 #else
254 namespace details
256 {
257
258 template<typename _tClass, typename _type>
259 struct is_callable_target
260 : is_base_of<member_target_type_t<_type>, _tClass>
261 {};
262
263 template<typename _fCallable, typename _type>
264 struct is_callable_case1 : and_<is_member_function_pointer<_fCallable>,
265 is_callable_target<_type&&, _fCallable>>
266 {};
267
268 template<typename _fCallable, typename _type>
269 struct is_callable_case2 : and_<is_member_function_pointer<_fCallable>,
270 not_<is_callable_target<_type&&, _fCallable>>>
271 {};
272
273 template<typename _fCallable, typename _type>
274 struct is_callable_case3 : and_<is_member_object_pointer<_fCallable>,
275 is_callable_target<_type&&, _fCallable>>
276 {};
277
278 template<typename _fCallable, typename _type>
279 struct is_callable_case4 : and_<is_member_object_pointer<_fCallable>,
280 not_<is_callable_target<_type&&, _fCallable>>>
281 {};
282
283 template<typename _fCallable, typename _type, typename... _tParams>
284 yconstfn auto
285 invoke_impl(_fCallable&& f, _type&& obj, _tParams&&... args)
286 -> enable_if_t<is_callable_case1<decay_t<_fCallable>, _type>::value,
287 decltype((obj.*f)(yforward(args)...))>
288 {
289 return yconstraint(f), (obj.*f)(yforward(args)...);
290 }
291 template<typename _fCallable, typename _type, typename... _tParams>
292 yconstfn auto
293 invoke_impl(_fCallable&& f, _type&& obj, _tParams&&... args)
294 -> enable_if_t<is_callable_case2<decay_t<_fCallable>, _type>::value,
295 decltype(((*yforward(obj)).*f)(yforward(args)...))>
296 {
297 return yconstraint(f), ((*yforward(obj)).*f)(yforward(args)...);
298 }
299 template<typename _fCallable, typename _type>
300 yconstfn auto
301 invoke_impl(_fCallable&& f, _type&& obj)
302 -> enable_if_t<is_callable_case3<decay_t<_fCallable>, _type>::value,
303 decltype(obj.*f)>
304 {
305 return yconstraint(f), obj.*f;
306 }
307 template<typename _fCallable, typename _type>
308 yconstfn auto
309 invoke_impl(_fCallable&& f, _type&& obj)
310 -> enable_if_t<is_callable_case4<decay_t<_fCallable>, _type>::value,
311 decltype((*yforward(obj)).*f)>
312 {
313 return yconstraint(f), (*yforward(obj)).*f;
314 }
315 template<typename _func, typename... _tParams>
316 yconstfn auto
317 invoke_impl(_func&& f, _tParams&&... args)
318 -> enable_if_t<!is_member_pointer<decay_t<_func>>::value,
319 decltype(yforward(f)(yforward(args)...))>
320 {
321 return yforward(f)(yforward(args)...);
322 }
323
324 } // namespace details;
325
335 template<typename _fCallable, typename... _tParams>
336 yimpl(yconstfn) result_of_t<_fCallable&&(_tParams&&...)>
337 invoke(_fCallable&& f, _tParams&&... args)
338 {
339 return details::invoke_impl(yforward(f), yforward(args)...);
340 }
341 #endif
342
343 namespace details
344 {
345
346 template<typename _fCallable, typename... _tParams>
347 yconstfn pseudo_output
348 invoke_nonvoid_impl(true_type, _fCallable&& f, _tParams&&... args)
349 {
350 return ystdex::invoke(yforward(f), yforward(args)...), pseudo_output();
351 }
352 template<typename _fCallable, typename... _tParams>
353 inline result_of_t<_fCallable&&(_tParams&&...)>
354 invoke_nonvoid_impl(false_type, _fCallable&& f, _tParams&&... args)
355 {
356 return ystdex::invoke(yforward(f), yforward(args)...);
357 }
358
359 } // namespace details;
360
365 template<typename _fCallable, typename... _tParams>
366 yimpl(yconstfn) nonvoid_result_t<result_of_t<_fCallable&&(_tParams&&...)>>
367 invoke_nonvoid(_fCallable&& f, _tParams&&... args)
368 {
369 return details::invoke_nonvoid_impl(is_void<result_of_t<
370 _fCallable&&(_tParams&&...)>>(), yforward(f), yforward(args)...);
371 }
372
373
380 template<typename>
381 struct make_parameter_tuple;
382
384 template<typename _fCallable>
385 using make_parameter_tuple_t = _t<make_parameter_tuple<_fCallable>>;
386
388 template<typename _fCallable>
389 struct make_parameter_tuple<_fCallable&> : make_parameter_tuple<_fCallable>
390 {};
391
393 template<typename _fCallable>
394 struct make_parameter_tuple<_fCallable&&> : make_parameter_tuple<_fCallable>
395 {};
396
397 #define YB_Impl_Functional_ptuple_spec(_exp, _p, _q) \
398 template<typename _tRet, _exp typename... _tParams> \
399 struct make_parameter_tuple<_tRet _p (_tParams...) _q> \
400 { \
401 using type = std::tuple<_tParams...>; \
402 };
403
404 YB_Impl_Functional_ptuple_spec(, , )
405 YB_Impl_Functional_ptuple_spec(, (*), )
406
407 #define YB_Impl_Functional_ptuple_spec_mf(_q) \
408 YB_Impl_Functional_ptuple_spec(class _tClass YPP_Comma, (_tClass::*), _q)
409
410 YB_Impl_Functional_ptuple_spec_mf()
412
413 YB_Impl_Functional_ptuple_spec_mf(const)
414 YB_Impl_Functional_ptuple_spec_mf(volatile)
415 YB_Impl_Functional_ptuple_spec_mf(const volatile)
417
418 #undef YB_Impl_Functional_ptuple_spec_mf
419
420 #undef YB_Impl_Functional_ptuple_spec
421
423 template<typename _tRet, typename... _tParams>
424 struct make_parameter_tuple<std::function<_tRet(_tParams...)>>
425 {
426 using type = std::tuple<_tParams...>;
427 };
429
430
437 template<typename>
438 struct return_of;
439
441 template<typename _fCallable>
442 using return_of_t = _t<return_of<_fCallable>>;
443
445 template<typename _fCallable>
446 struct return_of<_fCallable&> : return_of<_fCallable>
447 {};
448
450 template<typename _fCallable>
451 struct return_of<_fCallable&&> : return_of<_fCallable>
452 {};
453
454 #define YB_Impl_Functional_ret_spec(_exp, _p, _e, _q) \
455 template<typename _tRet, _exp typename... _tParams> \
456 struct return_of<_tRet _p (_tParams... YPP_Args _e) _q> \
457 { \
458 using type = _tRet; \
459 };
460
461 #define YB_Impl_Functional_ret_spec_f(_e) \
462 YB_Impl_Functional_ret_spec(, , _e, ) \
463 YB_Impl_Functional_ret_spec(, (*), _e, )
464
465 YB_Impl_Functional_ret_spec_f()
467 YB_Impl_Functional_ret_spec_f((, ...))
468
469 #undef YB_Impl_Functional_ret_spec_f
470
471 #define YB_Impl_Functional_ret_spec_mf(_e, _q) \
472 YB_Impl_Functional_ret_spec(class _tClass YPP_Comma, (_tClass::*), \
473 _e, _q)
474
475 #define YB_Impl_Functional_ret_spec_mfq(_e) \
476 YB_Impl_Functional_ret_spec_mf(_e, ) \
477 YB_Impl_Functional_ret_spec_mf(_e, const) \
478 YB_Impl_Functional_ret_spec_mf(_e, volatile) \
479 YB_Impl_Functional_ret_spec_mf(_e, const volatile)
480
481
482 YB_Impl_Functional_ret_spec_mfq()
484 YB_Impl_Functional_ret_spec_mfq((, ...))
485
486 #undef YB_Impl_Functional_ret_spec_mfq
487 #undef YB_Impl_Functional_ret_spec_mf
488
489 #undef YB_Impl_Functional_ret_spec
490
492 template<typename _tRet, typename... _tParams>
493 struct return_of<std::function<_tRet(_tParams...)>>
494 {
495 using type = _tRet;
496 };
498
499
506 template<size_t _vIdx, typename _fCallable>
507 struct parameter_of
508 {
509 using type = tuple_element_t<_vIdx,
510 _t<make_parameter_tuple<_fCallable>>>;
511 };
512
514 template<size_t _vIdx, typename _fCallable>
515 using parameter_of_t = _t<parameter_of<_vIdx, _fCallable>>;
517
518
524 template<typename _fCallable>
525 struct paramlist_size : integral_constant<size_t, std::tuple_size<typename
526 make_parameter_tuple<_fCallable>::type>::value>
527 {};
528
529
535
537 template<typename, class>
538 struct make_function_type;
539
540 template<typename _tRet, class _tTuple>
541 using make_function_type_t = _t<make_function_type<_tRet, _tTuple>>;
542
543 template<typename _tRet, typename... _tParams>
544 struct make_function_type<_tRet, std::tuple<_tParams...>>
545 {
546 using type = _tRet(_tParams...);
547 };
549
550
555 template<template<typename...> class _gOp, typename _func, typename... _tParams>
556 using enable_fallback_t = enable_if_t<!is_detected<_gOp, _tParams&&...>::value,
557 decltype(std::declval<_func>()(std::declval<_tParams&&>()...))>;
558
559
561 template<typename _type, size_t _vN = 1, typename _tParam = _type>
562 using id_func_t
563 = make_function_type_t<_type, vseq::join_n_t<_vN, std::tuple<_tParam>>>;
564
566 template<typename _type, size_t _vN = 1>
567 using id_func_clr_t = id_func_t<_type, _vN, const _type&>;
568
570 template<typename _type, size_t _vN = 1>
571 using id_func_rr_t = id_func_t<_type, _vN, _type&&>;
573
574
580 template<typename _func, typename... _tParams>
582 inline auto
583 bind1(_func&& f, _tParams&&... args) -> decltype(
584 std::bind(yforward(f), std::placeholders::_1, yforward(args)...))
585 {
586 return std::bind(yforward(f), std::placeholders::_1, yforward(args)...);
587 }
589 template<typename _tRes, typename _func, typename... _tParams>
590 inline auto
591 bind1(_func&& f, _tParams&&... args) -> decltype(
592 std::bind<_tRes>(yforward(f), std::placeholders::_1, yforward(args)...))
593 {
594 return std::bind<_tRes>(yforward(f), std::placeholders::_1, yforward(args)...);
595 }
597
604 template<typename _func, typename _func2, typename... _tParams>
605 inline auto
606 bind_forward(_func&& f, _func2&& f2, _tParams&&... args)
607 -> decltype(ystdex::bind1(yforward(f), std::bind(yforward(f2),
608 std::placeholders::_2, yforward(args)...)))
609 {
610 return ystdex::bind1(yforward(f), std::bind(yforward(f2),
611 std::placeholders::_2, yforward(args)...));
612 }
613
614
616
617 template<typename _func1, typename _func2>
619 struct composed
620 {
621 _func1 f;
622 _func2 g;
623
624 template<typename... _tParams>
625 yconstfn auto
626 operator()(_tParams&&... args) const -> decltype(f(g(yforward(args))...))
627 {
628 return f(g(yforward(args))...);
629 }
630 };
631
638 template<typename _func1, typename _func2>
639 composed<_func1, _func2>
640 compose(_func1 f, _func2 g)
641 {
642 return composed<_func1, _func2>{f, g};
643 }
644 template<typename _func1, typename _func2, typename... _funcs>
645 yconstfn auto
646 compose(_func1 f, _func2 g, _funcs... args)
647 -> decltype(ystdex::compose(ystdex::compose(f, g), args...))
648 {
649 return ystdex::compose(ystdex::compose(f, g), args...);
650 }
652
653
663 template<typename _func, typename _tRes = void, typename _tState = bool>
664 struct one_shot
665 {
666 static_assert(is_nothrow_move_constructible<_func>(),
667 "Invalid target type found.");
668 static_assert(is_nothrow_move_constructible<_tRes>(),
669 "Invalid result type found.");
670 static_assert(is_nothrow_default_constructible<_tState>(),
671 "Invalid state type found.");
672 static_assert(is_nothrow_swappable<_tState>(),
673 "Invalid state type found.");
674
675 _func func;
676 mutable _tRes result;
677 mutable _tState fresh{};
678
679 one_shot(_func f, _tRes r = {}, _tState s = {})
680 : func(f), result(r), fresh(s)
681 {}
682 one_shot(one_shot&& f) ynothrow
683 : func(std::move(f.func)), result(std::move(f.result))
684 {
685 using std::swap;
686
687 swap(fresh, f.fresh);
688 }
689
690 template<typename... _tParams>
691 yconstfn_relaxed auto
692 operator()(_tParams&&... args) const
693 ynoexcept(noexcept(func(yforward(args)...)))
694 -> decltype(func(yforward(args)...))
695 {
696 if(fresh)
697 {
698 result = func(yforward(args)...);
699 fresh = {};
700 }
701 return std::forward<_tRes>(result);
702 }
703 };
704
705 template<typename _func, typename _tState>
706 struct one_shot<_func, void, _tState>
707 {
708 static_assert(is_nothrow_move_constructible<_func>(),
709 "Invalid target type found.");
710 static_assert(is_nothrow_default_constructible<_tState>(),
711 "Invalid state type found.");
712 static_assert(is_nothrow_swappable<_tState>(),
713 "Invalid state type found.");
714
715 _func func;
716 mutable _tState fresh{};
717
718 one_shot(_func f, _tState s = {})
719 : func(f), fresh(s)
720 {}
721 one_shot(one_shot&& f) ynothrow
722 : func(std::move(f.func))
723 {
724 using std::swap;
725
726 swap(fresh, f.fresh);
727 }
728
729 template<typename... _tParams>
730 yconstfn_relaxed void
731 operator()(_tParams&&... args) const
732 ynoexcept(noexcept(func(yforward(args)...)))
733 {
734 if(fresh)
735 {
736 func(yforward(args)...);
737 fresh = {};
738 }
739 }
740 };
741
742 template<typename _func, typename _tRes>
743 struct one_shot<_func, _tRes, void>
744 {
745 static_assert(is_nothrow_move_constructible<_func>(),
746 "Invalid target type found.");
747 static_assert(is_nothrow_move_constructible<_tRes>(),
748 "Invalid result type found.");
749
750
751 mutable _func func;
752 mutable _tRes result;
753
754 one_shot(_func f, _tRes r = {})
755 : func(f), result(r)
756 {}
757
758 template<typename... _tParams>
759 yconstfn_relaxed auto
760 operator()(_tParams&&... args) const
761 ynoexcept(noexcept(func(yforward(args)...)))
762 -> decltype(func(yforward(args)...) && noexcept(func = {}))
763 {
764 if(func)
765 {
766 result = func(yforward(args)...);
767 func = {};
768 }
769 return std::forward<_tRes>(result);
770 }
771 };
772
773 template<typename _func>
774 struct one_shot<_func, void, void>
775 {
776 static_assert(is_nothrow_move_constructible<_func>(),
777 "Invalid target type found.");
778
779 mutable _func func;
780
781 one_shot(_func f)
782 : func(f)
783 {}
784
785 template<typename... _tParams>
786 yconstfn_relaxed void
787 operator()(_tParams&&... args) const
788 ynoexcept(noexcept(func(yforward(args)...) && noexcept(func = {})))
789 {
790 if(func)
791 {
792 func(yforward(args)...);
793 func = {};
794 }
795 }
796 };
798
799
805 template<typename _type>
806 using get_less
807 = composed<less<_type*>, composed<addressof_op<_type>, mem_get<>>>;
808
809
811 namespace details
812 {
813
814 template<typename _type, typename _fCallable, typename... _tParams>
815 _type
816 call_for_value(std::true_type, _type&& val, _fCallable&& f, _tParams&&... args)
817 {
818 ystdex::invoke(yforward(f), yforward(args)...);
819 return yforward(val);
820 }
821
822 template<typename _type, typename _fCallable, typename... _tParams>
823 auto
824 call_for_value(std::false_type, _type&&, _fCallable&& f, _tParams&&... args)
825 -> result_of_t<_fCallable&&(_tParams&&...)>
826 {
827 return ystdex::invoke(yforward(f), yforward(args)...);
828 }
829
830 } // unnamed namespace;
831
836 template<typename _type, typename _fCallable, typename... _tParams>
837 auto
838 call_for_value(_type&& val, _fCallable&& f, _tParams&&... args)
839 -> common_nonvoid_t<result_of_t<_fCallable&&(_tParams&&...)>, _type>
840 {
841 return details::call_for_value(bool_constant<
842 is_void<result_of_t<_fCallable&&(_tParams&&...)>>::value>(),
843 yforward(val), yforward(f), yforward(args)...);
844 }
845
846
852 template<class, class>
853 struct call_projection;
854
855 template<typename _tRet, typename... _tParams, size_t... _vSeq>
856 struct call_projection<_tRet(_tParams...), index_sequence<_vSeq...>>
857 {
859 template<typename _func>
860 static _tRet
861 call(_func&& f, std::tuple<_tParams...>&& args, yimpl(decay_t<
862 decltype(yforward(f)(std::get<_vSeq>(std::move(args))...))>* = {}))
863 {
864 return yforward(f)(std::get<_vSeq>(std::move(args))...);
865 }
867
868 template<typename _func>
869 static auto
870 call(_func&& f, _tParams&&... args)
871 -> decltype(call_projection::call(yforward(f),
872 std::forward_as_tuple(yforward(args)...)))
873 {
874 return call_projection::call(yforward(f),
875 std::forward_as_tuple(yforward(args)...));
876 }
877
878 template<typename _fCallable>
879 static _tRet
880 invoke(_fCallable&& f, std::tuple<_tParams...>&& args,
881 yimpl(decay_t<decltype(ystdex::invoke(yforward(f),
882 std::get<_vSeq>(std::move(args))...))>* = {}))
883 {
884 return ystdex::invoke(yforward(f), std::get<_vSeq>(std::move(args))...);
885 }
886 template<typename _func>
887 static auto
888 invoke(_func&& f, _tParams&&... args)
889 -> decltype(call_projection::invoke(yforward(f),
890 std::forward_as_tuple(yforward(args)...)))
891 {
892 return call_projection::invoke(yforward(f),
893 std::forward_as_tuple(yforward(args)...));
894 }
896 };
897
899 template<typename _tRet, typename... _tParams, size_t... _vSeq>
900 struct call_projection<std::function<_tRet(_tParams...)>,
901 index_sequence<_vSeq...>> : private
902 call_projection<_tRet(_tParams...), index_sequence<_vSeq...>>
903 {
905 using call_projection<_tRet(_tParams...), index_sequence<_vSeq...>>::call;
907 using
908 call_projection<_tRet(_tParams...), index_sequence<_vSeq...>>::invoke;
909 };
910
915 template<typename... _tParams, size_t... _vSeq>
916 struct call_projection<std::tuple<_tParams...>, index_sequence<_vSeq...>>
917 {
918 template<typename _func>
919 static auto
920 call(_func&& f, std::tuple<_tParams...>&& args)
921 -> decltype(yforward(f)(std::get<_vSeq>(std::move(args))...))
922 {
923 return yforward(f)(std::get<_vSeq>(std::move(args))...);
924 }
925
927
928 template<typename _func>
929 static auto
930 call(_func&& f, _tParams&&... args)
931 -> decltype(call_projection::call(yforward(f),
932 std::forward_as_tuple(yforward(std::move(args))...)))
933 {
934 return call_projection::call(yforward(f),
935 std::forward_as_tuple(yforward(std::move(args))...));
936 }
937
938 template<typename _fCallable>
939 static auto
940 invoke(_fCallable&& f, std::tuple<_tParams...>&& args)
941 -> decltype(ystdex::invoke(yforward(f), std::get<_vSeq>(args)...))
942 {
943 return ystdex::invoke(yforward(f), std::get<_vSeq>(args)...);
944 }
945 template<typename _func>
946 static auto
947 invoke(_func&& f, _tParams&&... args)
948 -> decltype(call_projection::invoke(yforward(f),
949 std::forward_as_tuple(yforward(args)...)))
950 {
951 return call_projection::invoke(yforward(f),
952 std::forward_as_tuple(yforward(args)...));
953 }
955 };
957
958
967 template<typename _func, class _tTuple>
968 inline auto
969 apply(_func&& f, _tTuple&& args)
970 -> yimpl(decltype(call_projection<_tTuple, make_index_sequence<
971 std::tuple_size<decay_t<_tTuple>>::value>>::call(yforward(f),
972 yforward(args))))
973 {
974 return call_projection<_tTuple, make_index_sequence<std::tuple_size<
975 decay_t<_tTuple>>::value>>::call(yforward(f), yforward(args));
976 }
977
978
980
981 template<typename _fCallable, size_t _vLen = paramlist_size<_fCallable>::value>
982 struct expand_proxy : private call_projection<_fCallable,
983 make_index_sequence<_vLen>>, private expand_proxy<_fCallable, _vLen - 1>
984 {
985 using call_projection<_fCallable, make_index_sequence<_vLen>>::call;
990 template<typename... _tParams>
991 static auto
992 call(_tParams&&... args)
993 -> decltype(expand_proxy<_fCallable, _vLen - 1>::call(yforward(args)...))
994 {
995 return expand_proxy<_fCallable, _vLen - 1>::call(yforward(args)...);
996 }
997 };
998
999 template<typename _fCallable>
1000 struct expand_proxy<_fCallable, 0>
1001 : private call_projection<_fCallable, index_sequence<>>
1002 {
1003 using call_projection<_fCallable, index_sequence<>>::call;
1004 };
1006
1007
1017 template<typename _fCond, typename _fCallable, typename... _tParams>
1018 result_of_t<_fCallable&&(_tParams&&...)>
1019 retry_on_cond(_fCond cond, _fCallable&& f, _tParams&&... args)
1020 {
1021 using res_t = result_of_t<_fCallable&&(_tParams&&...)>;
1022 using obj_t = object_result_t<res_t>;
1023 obj_t res;
1024
1025 do
1026 res = ystdex::invoke_nonvoid(yforward(f), yforward(args)...);
1027 while(expand_proxy<bool(obj_t&)>::call(cond, res));
1028 return res_t(res);
1029 }
1030
1031
1037 template<typename _fHandler, typename _fCallable>
1038 struct expanded_caller
1039 {
1041 static_assert(is_object<_fCallable>(), "Callable object type is needed.");
1042
1044 _fCallable caller;
1045
1047 template<typename _fCaller,
1048 yimpl(typename = exclude_self_t<expanded_caller, _fCaller>)>
1049 expanded_caller(_fCaller&& f)
1050 : caller(yforward(f))
1051 {}
1052
1054 template<typename... _tParams>
1055 auto
1056 operator()(_tParams&&... args) const -> decltype(
1057 expand_proxy<_fHandler>::call(caller, yforward(args)...))
1058 {
1059 return expand_proxy<_fHandler>::call(caller, yforward(args)...);
1060 }
1061 };
1062
1069 template<typename _fHandler, typename _fCallable>
1070 yconstfn expanded_caller<_fHandler, decay_t<_fCallable>>
1071 make_expanded(_fCallable&& f)
1072 {
1073 return expanded_caller<_fHandler, decay_t<_fCallable>>(yforward(f));
1074 }
1075
1076
1083 template<typename _type>
1084 struct default_last_value
1085 {
1086 template<typename _tIn>
1087 _type
1088 operator()(_tIn first, _tIn last, const _type& val = {}) const
1089 {
1090 return std::accumulate(first, last, val,
1091 [](_type&, decltype(*first) v){
1092 return yforward(v);
1093 });
1094 }
1095 };
1096
1097 template<>
1098 struct default_last_value<void>
1099 {
1100 template<typename _tIn>
1101 void
1102 operator()(_tIn first, _tIn last) const
1103 {
1104 for(; first != last; ++first)
1105 *first;
1106 }
1107 };
1109
1110 } // namespace ystdex;
1111
1112 #endif
1113
ystdex::common_nonvoid_t
_t< cond_t< is_void< _type >, vdefer< common_type_t, _types... >, identity< _type >>> common_nonvoid_t
取公共非空类型：若第一参数为非空类型则为第一参数，否则从其余参数推断。
Definition: type_op.hpp:290
ystdex::composed::operator()
auto operator()(_tParams &&...args) const -> decltype(f(g(std::forward< decltype(args)>(args))...))
Definition: functional.hpp:626
ystdex::one_shot< _func, void, void >::operator()
void operator()(_tParams &&...args) const
Definition: functional.hpp:787
ystdex::composed
复合函数。
Definition: functional.hpp:619
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
ystdex::one_shot< _func, void, void >::func
_func func
Definition: functional.hpp:777
ystdex::nonvoid_result_t
cond_t< not_< is_void< _type >>, _type, pseudo_output > nonvoid_result_t
若类型不是空类型则取后备结果类型（默认为 pseudo_output ）。
Definition: ref.hpp:288
ystdex::one_shot< _func, void, _tState >::func
_func func
Definition: functional.hpp:709
ystdex::details::tuple_element_convertible< std::tuple< _types1... >, std::tuple< _types2... >, index_sequence< _vHead, _vSeq... > >::t2
std::tuple< _types2... > t2
Definition: functional.hpp:66
ystdex::id_func_t
make_function_type_t< _type, vseq::join_n_t< _vN, std::tuple< _tParam >>> id_func_t
取指定维数和指定参数类型的多元映射扩展恒等函数类型。
Definition: functional.hpp:563
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:82
ystdex::is_detected
typename details::detector< nonesuch, void, _gOp, _tParams... >::value_t is_detected
Definition: type_traits.hpp:667
ystdex::variadic_param::get
static auto get(_type &&, _tParams &&...args) -> decltype(variadic_param< _vN-1 >::get(std::forward< decltype(args)>(args)...))
Definition: functional.hpp:159
ystdex::default_last_value
合并值序列。
Definition: functional.hpp:1084
ystdex::swap
void swap(container_adaptor< _tSeqCon > &x, container_adaptor< _tSeqCon > &y)
Definition: container.hpp:179
v
byte v
Definition: CharRenderer.cpp:75
ystdex::unseq_apply
void unseq_apply(_func &&f, _tParams &&...args)
无序调用。
Definition: functional.hpp:241
YB_Impl_Functional_ptuple_spec_mf
#define YB_Impl_Functional_ptuple_spec_mf(_q)
Definition: functional.hpp:407
YB_Impl_Functional_ret_spec_mfq
#define YB_Impl_Functional_ret_spec_mfq(_e)
Definition: functional.hpp:475
ystdex::apply
auto apply(_func &&f, _tTuple &&args) -> decltype(call_projection< _tTuple, make_index_sequence< std::tuple_size< decay_t< _tTuple >>::value >>::call(std::forward< decltype(f)>(f), std::forward< decltype(args)>(args)))
应用函数对象和参数元组。
Definition: functional.hpp:969
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:350
ystdex::call_for_value
auto call_for_value(_type &&val, _fCallable &&f, _tParams &&...args) -> common_nonvoid_t< result_of_t< _fCallable &&(_tParams &&...)>, _type >
调用第二个参数起指定的函数对象，若返回空类型则使用第一个参数的值为返回值。
Definition: functional.hpp:838
ystdex::parameter_of::type
tuple_element_t< _vIdx, _t< make_parameter_tuple< _fCallable >>> type
Definition: functional.hpp:510
ystdex::expanded_caller::expanded_caller
expanded_caller(_fCaller &&f)
Definition: functional.hpp:1049
ystdex::details::call_for_value
_type call_for_value(std::true_type, _type &&val, _fCallable &&f, _tParams &&...args)
Definition: functional.hpp:816
ystdex::enable_fallback_t
enable_if_t<!is_detected< _gOp, _tParams &&... >::value, decltype(std::declval< _func >()(std::declval< _tParams && >()...))> enable_fallback_t
启用备用重载。
Definition: functional.hpp:557
ystdex::one_shot
调用一次的函数包装模板。
Definition: functional.hpp:664
ystdex::one_shot::fresh
_tState fresh
Definition: functional.hpp:677
ystdex::one_shot< _func, _tRes, void >::result
_tRes result
Definition: functional.hpp:752
ystdex::one_shot::operator()
auto operator()(_tParams &&...args) const -> decltype(func(std::forward< decltype(args)>(args)...))
Definition: functional.hpp:692
ystdex::is_covariant
判断指定类型之间是否协变。
Definition: functional.hpp:84
ystdex::details::is_callable_case4
Definition: functional.hpp:279
ystdex::one_shot< _func, void, _tState >::one_shot
one_shot(one_shot &&f)
Definition: functional.hpp:721
ystdex::invoke_nonvoid
nonvoid_result_t< result_of_t< _fCallable &&(_tParams &&...)> > invoke_nonvoid(_fCallable &&f, _tParams &&...args)
调用可调用对象，保证返回值非空。
Definition: functional.hpp:367
ystdex::details::is_callable_case1
Definition: functional.hpp:264
ystdex::bool_constant
integral_constant< bool, _b > bool_constant
bool 常量。
Definition: type_traits.hpp:382
ystdex::invoke
result_of_t< _fCallable &&(_tParams &&...)> invoke(_fCallable &&f, _tParams &&...args)
调用可调用对象。
Definition: functional.hpp:337
ystdex::parameter_of_t
_t< parameter_of< _vIdx, _fCallable >> parameter_of_t
Definition: functional.hpp:515
ystdex::one_shot::one_shot
one_shot(_func f, _tRes r={}, _tState s={})
Definition: functional.hpp:679
ystdex::one_shot< _func, _tRes, void >::operator()
auto operator()(_tParams &&...args) const -> decltype(func(std::forward< decltype(args)>(args)...)&&noexcept(func=
Definition: functional.hpp:760
ystdex::exclude_self_t
enable_if_t<!is_same< _tClass &, decay_t< _tParam > & >::value, _type > exclude_self_t
移除选择类类型的特定重载避免构造模板和复制/转移特殊成员函数冲突。
Definition: type_traits.hpp:708
ystdex::call_projection< _tRet(_tParams...), index_sequence< _vSeq... > >::call
static _tRet call(_func &&f, std::tuple< _tParams... > &&args, decay_t< decltype(std::forward< decltype(f)>(f)(std::get< _vSeq >(std::move(args))...))> *={})
Definition: functional.hpp:861
ystdex::details::invoke_nonvoid_impl
pseudo_output invoke_nonvoid_impl(true_type, _fCallable &&f, _tParams &&...args)
Definition: functional.hpp:348
ystdex::call_projection< std::tuple< _tParams... >, index_sequence< _vSeq... > >::invoke
static auto invoke(_func &&f, _tParams &&...args) -> decltype(call_projection::invoke(std::forward< decltype(f)>(f), std::forward_as_tuple(std::forward< decltype(args)>(args)...)))
Definition: functional.hpp:947
ystdex::is_contravariant
判断指定类型之间是否逆变。
Definition: functional.hpp:112
ystdex::cpp2014::tuple_element_t
_t< std::tuple_element< _vIdx, _type >> tuple_element_t
Definition: tuple.hpp:50
ystdex::is_nothrow_swappable
Definition: type_traits.hpp:530
ystdex::one_shot::result
_tRes result
Definition: functional.hpp:676
yimpl
#define yimpl(...)
实现标签。
Definition: ydef.h:256
ystdex::id_func_rr_t
id_func_t< _type, _vN, _type && > id_func_rr_t
取指定维数和 const 右值引用参数类型的多元映射扩展恒等函数类型。
Definition: functional.hpp:571
ystdex::id_func_clr_t
id_func_t< _type, _vN, const _type & > id_func_clr_t
取指定维数和 const 左值引用参数类型的多元映射扩展恒等函数类型。
Definition: functional.hpp:567
ystdex::vseq::at
取指定位置的元素。
Definition: variadic.hpp:467
ystdex::one_shot< _func, void, _tState >::operator()
void operator()(_tParams &&...args) const
Definition: functional.hpp:731
ystdex::cpp2014::index_sequence
integer_sequence< size_t, _vSeq... > index_sequence
Definition: integer_sequence.hpp:63
ystdex::make_parameter_tuple_t
_t< make_parameter_tuple< _fCallable >> make_parameter_tuple_t
Definition: functional.hpp:385
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:768
ystdex::expand_proxy::call
static auto call(_tParams &&...args) -> decltype(expand_proxy< _fCallable, _vLen-1 >::call(std::forward< decltype(args)>(args)...))
Definition: functional.hpp:992
ystdex::details::tuple_element_convertible
Definition: functional.hpp:49
ystdex::variadic_param
变长参数操作模板。
Definition: functional.hpp:154
ystdex::one_shot< _func, _tRes, void >::func
_func func
Definition: functional.hpp:746
ystdex::details::invoke_impl
auto invoke_impl(_fCallable &&f, _type &&obj, _tParams &&...args) -> enable_if_t< is_callable_case1< decay_t< _fCallable >, _type >::value, decltype((obj.*f)(std::forward< decltype(args)>(args)...))>
Definition: functional.hpp:285
yconstfn_relaxed
#define yconstfn_relaxed
指定编译时没有 C++11 限制和隐式成员 const 的常量函数。
Definition: ydef.h:666
std
Definition: memory.hpp:1100
ystdex::expanded_caller
接受冗余参数的可调用对象。
Definition: functional.hpp:1038
ystdex::_t
typename _type::type _t
嵌套类型别名。
Definition: type_traits.hpp:96
ystdex::expanded_caller::make_expanded
expanded_caller< _fHandler, decay_t< _fCallable > > make_expanded(_fCallable &&f)
构造接受冗余参数的可调用对象。
Definition: functional.hpp:1071
ystdex::composed::g
_func2 g
Definition: functional.hpp:622
ystdex::make_function_type< _tRet, std::tuple< _tParams... > >::type
_tRet(_tParams...) type
Definition: functional.hpp:546
ystdex::expanded_caller::operator()
auto operator()(_tParams &&...args) const -> decltype(expand_proxy< _fHandler >::call(caller, std::forward< decltype(args)>(args)...))
Definition: functional.hpp:1056
ystdex::one_shot::one_shot
one_shot(one_shot &&f)
Definition: functional.hpp:682
YB_Impl_Functional_ret_spec_f
#define YB_Impl_Functional_ret_spec_f(_e)
Definition: functional.hpp:461
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
ystdex::call_projection< std::tuple< _tParams... >, index_sequence< _vSeq... > >::call
static auto call(_func &&f, _tParams &&...args) -> decltype(call_projection::call(std::forward< decltype(f)>(f), std::forward_as_tuple(std::forward< decltype(std::move(args))>(std::move(args))...)))
Definition: functional.hpp:930
ystdex::bind1
auto bind1(_func &&f, _tParams &&...args) -> decltype(std::bind(std::forward< decltype(f)>(f), std::placeholders::_1, std::forward< decltype(args)>(args)...))
复合调用 std::bind 和 std::placeholders::_1 。
Definition: functional.hpp:583
ystdex::return_of
取返回类型。
Definition: functional.hpp:438
ystdex
特性测试宏。
Definition: ydef.h:796
ystdex::cpp2014::decay_t
typename decay< _type >::type decay_t
Definition: type_traits.hpp:347
ystdex::make_function_type_t
_t< make_function_type< _tRet, _tTuple >> make_function_type_t
Definition: functional.hpp:541
functor.hpp
通用仿函数。
ystdex::default_last_value< void >::operator()
void operator()(_tIn first, _tIn last) const
Definition: functional.hpp:1102
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
ystdex::details::is_callable_case2
Definition: functional.hpp:269
ystdex::paramlist_size
取参数列表大小。
Definition: functional.hpp:525
ystdex::pseudo_output
伪输出对象。
Definition: ref.hpp:254
ystdex::mem_get
成员 get 操作。
Definition: functor.hpp:158
ystdex::make_parameter_tuple
取参数列表元组。
Definition: functional.hpp:381
ystdex::expanded_caller::caller
_fCallable caller
Definition: functional.hpp:1041
ystdex::return_of< std::function< _tRet(_tParams...)> >::type
_tRet type
Definition: functional.hpp:495
ystdex::varg
auto varg(_tParams &&...args) -> decltype(variadic_param< _vN >::get(std::forward< decltype(args)>(args)...))
取指定位置的变长参数。
Definition: functional.hpp:189
ystdex::call_projection< _tRet(_tParams...), index_sequence< _vSeq... > >::invoke
static auto invoke(_func &&f, _tParams &&...args) -> decltype(call_projection::invoke(std::forward< decltype(f)>(f), std::forward_as_tuple(std::forward< decltype(args)>(args)...)))
Definition: functional.hpp:888
ynoexcept
#define ynoexcept(...)
YSLib 无异常抛出保证：指定特定的异常规范。
Definition: ydef.h:720
ystdex::make_parameter_tuple< std::function< _tRet(_tParams...)> >::type
std::tuple< _tParams... > type
Definition: functional.hpp:426
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:654
ystdex::make_function_type
取指定返回类型和元组指定参数类型的函数类型。
Definition: functional.hpp:538
type_op.hpp
C++ 类型操作。
ystdex::call_projection< std::tuple< _tParams... >, index_sequence< _vSeq... > >::invoke
static auto invoke(_fCallable &&f, std::tuple< _tParams... > &&args) -> decltype(ystdex::invoke(std::forward< decltype(f)>(f), std::get< _vSeq >(args)...))
Definition: functional.hpp:940
ystdex::composed::compose
composed< _func1, _func2 > compose(_func1 f, _func2 g)
函数复合。
Definition: functional.hpp:640
ystdex::details::is_callable_target
Definition: functional.hpp:259
ystdex::details::tuple_element_convertible< std::tuple< _types1... >, std::tuple< _types2... >, index_sequence< _vHead, _vSeq... > >::t1
std::tuple< _types1... > t1
Definition: functional.hpp:65
ystdex::sizeof_params
size_t sizeof_params(_tParams &&...)
统计函数参数列表中的参数个数。
Definition: functional.hpp:143
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:969
ystdex::cpp2014::make_index_sequence
make_integer_sequence< size_t, _vN > make_index_sequence
Definition: integer_sequence.hpp:233
ystdex::compose
auto compose(_func1 f, _func2 g, _funcs...args) -> decltype(ystdex::compose(ystdex::compose(f, g), args...))
Definition: functional.hpp:646
ystdex::composed::f
_func1 f
Definition: functional.hpp:621
ystdex::get_less
composed< less< _type * >, composed< addressof_op< _type >, mem_get<>>> get_less
get 成员小于仿函数。
Definition: functional.hpp:807
ystdex::one_shot< _func, void, void >::one_shot
one_shot(_func f)
Definition: functional.hpp:781
ystdex::call_projection< _tRet(_tParams...), index_sequence< _vSeq... > >::call
static auto call(_func &&f, _tParams &&...args) -> decltype(call_projection::call(std::forward< decltype(f)>(f), std::forward_as_tuple(std::forward< decltype(args)>(args)...)))
Definition: functional.hpp:870
ystdex::parameter_of
取指定索引的参数类型。
Definition: functional.hpp:507
YSLib::IO::f
const string &path const String &path _func f
Definition: YSLib/Service/FileSystem.h:430
ystdex::retry_on_cond
result_of_t< _fCallable &&(_tParams &&...)> retry_on_cond(_fCond cond, _fCallable &&f, _tParams &&...args)
循环重复调用：代替直接使用 do-while 语句以避免过多引入作用域外的变量。
Definition: functional.hpp:1019
ystdex::default_last_value::operator()
_type operator()(_tIn first, _tIn last, const _type &val={}) const
Definition: functional.hpp:1088
ystdex::one_shot< _func, _tRes, void >::one_shot
one_shot(_func f, _tRes r={})
Definition: functional.hpp:754
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
ystdex::one_shot< _func, void, _tState >::one_shot
one_shot(_func f, _tState s={})
Definition: functional.hpp:718
ystdex::seq_apply
void seq_apply(_func &&)
顺序递归调用。
Definition: functional.hpp:225
ystdex::expand_proxy
Definition: functional.hpp:982
ystdex::details::is_callable_case3
Definition: functional.hpp:274
ystdex::bind_forward
auto bind_forward(_func &&f, _func2 &&f2, _tParams &&...args) -> decltype(ystdex::bind1(std::forward< decltype(f)>(f), std::bind(std::forward< decltype(f2)>(f2), std::placeholders::_2, std::forward< decltype(args)>(args)...)))
复合调用 ystdex::bind1 和 std::placeholders::_2 以实现值的设置。
Definition: functional.hpp:606
YSLib::Drawing::g
The boundary is out of the const Graphics & g
Definition: YDraw.h:161
ystdex::return_of_t
_t< return_of< _fCallable >> return_of_t
Definition: functional.hpp:442
ystdex::and_
逻辑操作元函数。
Definition: type_traits.hpp:394
ystdex::cpp2014::result_of_t
typename result_of< _type >::type result_of_t
Definition: type_traits.hpp:362
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140
ystdex::object_result_t
cond_t< is_object< _type >, _type, pseudo_output > object_result_t
若类型不是对象类型则取后备结果类型（默认为 pseudo_output ）。
Definition: ref.hpp:292
ystdex::call_projection
调用投影：向原调用传递序列指定的位置的参数。
Definition: functional.hpp:853
ystdex::call_projection< std::tuple< _tParams... >, index_sequence< _vSeq... > >::call
static auto call(_func &&f, std::tuple< _tParams... > &&args) -> decltype(std::forward< decltype(f)>(f)(std::get< _vSeq >(std::move(args))...))
Definition: functional.hpp:920
ystdex::one_shot::func
_func func
Definition: functional.hpp:667
ystdex::call_projection< _tRet(_tParams...), index_sequence< _vSeq... > >::invoke
static _tRet invoke(_fCallable &&f, std::tuple< _tParams... > &&args, decay_t< decltype(ystdex::invoke(std::forward< decltype(f)>(f), std::get< _vSeq >(std::move(args))...))> *={})
Definition: functional.hpp:880
ystdex::chain_apply
void chain_apply(_func &&f)
顺序链式调用。
Definition: functional.hpp:206
YB_Impl_Functional_ptuple_spec
#define YB_Impl_Functional_ptuple_spec(_exp, _p, _q)
Definition: functional.hpp:397