C++ Async

Unfortunately, it is impossible to use async to call a member method of an instance object of a template class. This is riddling me, because you can call a template function if specifying an "instance" of that function using decltype.
You also can call a member method of an instance of a non-template class.
But trying the same thing with an instance of a template class does not work with async, mainly because the error produced by the compiler originally seems to come from std::tuple instead from std::async.
So in my opinion, the culprit is tuple.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <future>

template <class T>
class Class
{
public:
	void member_method()
	{
		std::cout << "It seems to work...\n";
	}
};

int main()
{
	Class<int> instance;
	
	std::async(std::launch::async, &Class<int>::member_method, instance).wait();
}
Topic archived. No new replies allowed.