In my app I would like to pass in a parameter pack over a legacy function signature, and change the values. Here is code that illustrates my question with my attempts as comments:
#include <tuple>
#include <cassert>
void LegacySignature( void* param );
template< typename... ArgsT >
// using ???; // attempt: can 'template alias' or 'using declaration' make the pack's type visible so I can use it inside the LegacyFunction?
void MyFunc( ArgsT&... args )
{
auto userArgsTuple = std::forward_as_tuple< ArgsT&... >( args... );
LegacySignature( &userArgsTuple );
}
void LegacySignature( void* param )
{
// auto userArgsTuple = reinterpret_cast<???>( param ); // attempt: how can I get the parameter pack's type declared so I can use it here?
// do something with the params like change num to 44 and tf to true;
//userArgsTuple->num = 44; // desired functionality
//userArgsTuple->tf = true; // desired functionality
}
int main()
{
int num { 33 };
bool tf { false };
MyFunc( num, tf );
assert( num == 44 && tf == true );
return 0;
}
Is there a way to make the parameter pack a declarable lvalue?
void*
and some other args they provide. You want to pass some data through thevoid*
so it is passed back to you at the other end. They won't store your callback or yourvoid*
longer than a fixed scope you have control over. Is this correct? Question: is thevoid*
passed as the first, or last, parameter to your callback function? – Irrefrangiblevoid*
was merely my attempt at representing the actual signature as a neutral type for discussion’s sake. In fact the actual signature parameter is the venerableLPARAM
which is along
. As MS states, bothWPARAM
andLPARAM
are “Types use for passing & returning polymorphic values”. As such, no Callbacks are being passed or invoked in my question. My interest lies directly in a better understanding of how to forward an arbitrary number of arguments across such a legacy construct, where these parameters are value-changeable references in a smart pointer. – Wilinskifuture
See StackOverflow issue [How can I use shared_ptr using PostThreadMessage?]( stackoverflow.com/questions/25667226) and look for the Answer that begins with @Remy Lebeau and @Wilinski have so far submitted two answers to my original posting…. – Wilinski