Christopher J. Pisz
unread,Jan 25, 2017, 8:45:22 AM1/25/17You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I am trying to try out std::async and futures
In order to do this, I need to bind a class method I would like run
async. The class method in question has overloads. One version is the
top level, another is the recursive portion. etc.
What is the bind syntax?
It usually has worked fine for me with
std::bind(&MyClass::MyMethod, this, std::placeholders::_1);
but now I am dealing with an overloaded method with multiple arguments.
I am trying and failing with:
//------------------------------------------------------------------------------
MyThing::Permutations MyThing::GetPermutations() const
{
std::vector<std::future<Permutations> > futures;
auto func = std::bind<MyThing::Permutations(size_t,
size_t)>(&MyThing::GetPermutations, this, std::placeholders::_1,
std::placeholders::_2);
/*
for( size_t x = 0; x < m_numColumns; ++x )
{
for( size_t y = 0; y < m_numRows; ++y )
{
std::async(std::launch::async, &Board::GetPermutations,
this, x, y);
}
}
*/
GetPermutations(0, 0);
}
with a class that looks like:
//------------------------------------------------------------------------------
class MyThing
{
public:
typedef std::vector<std::string> Permutations;
MyThing();
~MyThing();
Permutations GetPermutations() const;
protected:
typedef std::vector<std::vector<bool> > UsedMap;
Permutations GetPermutations(size_t startingCoordinates_X
, size_t startingCoordinates_Y) const;
Permutations GetPermutations(size_t startingCoordinates_X
, size_t startingCoordinates_Y
, UsedMap usedMap) const;
};