Reputation: 2863
I have a class looks like this:
class MyClass {
static Microsoft::WRL::ComPtr<ID3D11VertexShader> vertexShader;
static void Setup(Device* device) {
auto createVSTask = loadVSTask.then([this, device]() {
DX::ThrowIfFailed(
device->CreateVertexShader(&vertexShader));
}
}
I can't use this
in the lambda because the function is static. What should I use instead?
Upvotes: 0
Views: 163
Reputation: 16737
You don't need a this
pointer to access static methods or variables. Simply remove this
from your capture list and the code will work.
static void Setup(Device* device) {
auto createVSTask = loadVSTask.then([device]() {
DX::ThrowIfFailed(
device->CreateVertexShader(&vertexShader));
}
Upvotes: 2
Reputation: 303057
You don't need to capture this
in order to have access to vertexShader
... it's already accessible. All you need is to capture device
:
static void Setup(Device* device) {
auto createVSTask = loadVSTask.then([device]{
DX::ThrowIfFailed(device->CreateVertexShader(&vertexShader));
});
}
Upvotes: 1