C++ How to store a parameter pack as a variable -
Currently I'm having trouble storing a parameter pack, this is the example code of the design:
Template & lt; Typename Func, typename ... Args & gt; Zero Handluffs (Funk Funk, ARGs & AGRG) {Strict Nest} (Fnac Nestfunk; Argus ... Nest Argus; // I do not know what to set up wrong (fnks funk, arges ... args) {nestFunc = func; NestArgs = (Args) ...; // so I can set it // // later I will forward it and the function is unsigned process () (nestFunc (std :: forward & lt; argee & gt; (nestArgs) without its arguments ... ); // Return to here 0;}}; nests * myNest; MyNest-> Setup (Funk, (Args) ...);} For this problem There is an example of all the things involved, I need to archive the arguments to request later in my Nest Structure. Well, if you have any way to store it but to set it, it is different for me, please tell me about it also. Thanks.
You must use the :: std :: tuple & lt; ARG ... & gt; to store it but then the question This is how when you need it, then how to open it. You need to use a technique called 'index' for this. Then, here A is a link to a place where I have been around. The most relevant category is that there is a type of centralized suspended_call .
In just a little bit, I will extract the most related bits and put them in the context of your code.
:
auto-saved_organis = :: std :: make_tuple (:: std :: move (args) ...); I save the argument in a Tupal I used the :: std :: move , and I think that doing this is the right thing to do. But it is possible that I am wrong and should use the :: std :: forward . I have never been clarified on a different difference than the signaling intent. The code which actually calls with saved arguments can be found. Now the code is absolutely specific what I am doing. The indicator moves are applied to apply a packet of integers in the implementing bit, which for the index is :: std :: get & lt; I & gt; To use this template as a template, once you have obtained this pack of integers, you can use it to get all the tuple elements in the form of personal arguments. :: std :: get to expand the call. will try to come up with a code that does in a relatively simple way:
#include & lt; Tuple & gt; # Include & lt; Cstddef & gt; #include & lt; String & gt; # Include & lt; Utility & gt; Template & lt; :: std :: size_t ... index & gt; Structure index {}; Template & lt; :: std :: size_t N, :: std :: size_t ... is & gt; Structure build_indices: build_indices & lt; N-1, N-1, is ... & gt; {}; Template & lt; :: std :: size_t ... is & gt; Struct build_indices & lt; 0, is ... & gt; : Index & lt; Is ... & gt; {}; Template & lt; Typename FuncT, typename ArgTuple, :: std :: size_t ... index & gt; Auto Call (Constant and F, Agustur & amp; Augs, Conte Indexes & lt; Indi ... & gt; & amp; amp;) - & gt; Decltype (f (:: std :: get & lt; indices & gt; (:: std :: forward & lt; ArgTuple & gt; (args)) ...) {return :: std :: move (f ( :: std :: get & lt; indices & gt; (:: STD are ahead & lt ::; ArgTuple & gt; (args)) ...);} Templates & gt; typename FuncT, typename ArgTuple & gt; ; Auto Call (Constant Fan and F, Ertple and Egg) -> gt; Decltype (call (f, args, build_index & lt; :: std :: tuple_size & lt; ArgTuple & gt; :: value & gt; { }) {Const build_indices Many of these codes were borrowed.
In addition to this, it is a sample that you have to adapt slightly to your specific situation. Basically, simply call Nestfunk, Saved_Arg) Say Somewhere
Comments
Post a Comment