#include <iostream>
#include <thread>
using namespace std;

class Thread {
public:

	typedef void (thread::*Action)();

	Thread(thread && t, Action a) : th(move(t)), pAction(a) {}

	~Thread()
	{
		if (th.joinable()) (th.*pAction)();
	}

private:

	Action pAction;
	thread th;
};

void work()
{
}

int main()
{
	Thread t1(thread(work), &thread::join); 
	Thread t2(thread(work), &thread::detach);
}
