I have the following code using variadic templates to call std::async,
struct TestParent
{
template< typename Fn, typeName ...Args >
bool checkBlock( bool& toCheck,
Fn&& fn, Args&& ... args )
{
int startIndx = 0;
int endIndx = 10;
std::future< bool > tk( std::async( std::launch, fn, this,
startIndx, endIndx,
toCheck, args ... ) );
return tk.get();
}
}
struct TestChild: public TestParent
{
bool checkRules( const int, const int, bool& std::vector< bool >& );
bool check();
}
bool TestChild::checkRules( const int startIndx, const int endIndx,
bool& toCheck,
std::vector< bool >& results )
{
toCheck = true;
for ( int indx = startIndx; indx < endIndx; ++ indx )
{
bool checkedOk;
... do something checking.
results.push_back( checkedOk );
}
return true;
}
bool TestChild::check()
{
bool toCheck;
std::vector< bool > results;
return checkBlock( toCheck, &testChild::checkRules, this, &results);
}
But I'm getting the following compilation error message:
no matching function for call to 'async(std::launch, bool (TestChild::&)(int, int, bool&, std::vector&), TestParent, int&, int&, bool&, TestChild*&, std::vector*&)' startInx, endInx, nothingToCheck, args ... ) );
I think it might have something to do with the fact that I'm passing additional parameters along with a parameter pack. Anyone has any ideas what's wrong with this, and what I should do to get this to work?