เป็นไปได้และจะเรียกใช้ฟังก์ชันสมาชิกเทมเพลตของคลาสโดยใช้ std::async ได้อย่างไร (ควรไม่ใช้ std::bind) โปรดอธิบายว่ามาตรฐาน C++11 หรือ C++14 อนุญาตให้มีการเรียกโดยทั่วไปหรือไม่ และวิธีทำให้มันทำงานใน MSVS2013 โดยเฉพาะ
#include <future>
template<typename T> void non_member_template(T val) {}
struct X
{
void member_non_template(int val) {}
template<typename T> void member_template(T val) {}
void call()
{
int val = 123;
std::async(std::launch::async, &non_member_template<int>, val); // ok
std::async(std::launch::async, &X::member_non_template, this, val); // ok
std::async(std::launch::async, &X::member_template<int>, this, val); // error
}
};
int main()
{
X x;
x.call();
}
MSB6006: "CL.exe" exited with code 1.
และไม่มีข้อมูลอื่น ๆ - person derpface   schedule 16.01.2015std::async(std::launch::async, (void(X::*)(int))&X::member_template<int>, this, val);
- person Axalo   schedule 17.01.2015