1
void D3DMiddleware::Capture(RemoteCall::Buffer params)
{
    D3DFuncs::AfterEndScene()->once([params] (HRESULT &ret) -> void {
            if (SUCCEEDED(ret))
            {
                ...
                params.Return(&result);
            }
            else
            {
                params.Return();
            }
        });
}

the compiler says, cant conver "this" from "const RemoteCall::Buffer" to "RemoteCall::Buffer &"

why params become const? in vs2012

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
QingYun
  • 859
  • 2
  • 8
  • 16
  • 2
    lambdas are const by default, you want a `mutable` lambda. Imagine a functor with a member function `void operator()() const`. `mutable` removes the const qualifier from the imaginary compiler generated functor. – mythagel Mar 05 '13 at 04:07
  • 1
    Try `[&params]` in lambda's capture list – borisbn Mar 05 '13 at 04:28
  • Are you sure you want to capture `params` by value (rather than by reference)? If I understand your code, it's a buffer that you want the lambda to fill for you. Capturing by reference is probably what you want, and then the const-problem will go away. – jogojapan Mar 05 '13 at 04:32

0 Answers0