테스트 예제:
14] auto Test{_STD make_unique<TStringList>()};
15] [](TStrings * Var) {
16] Var->Values["Key"] = "Value";
17] }(Test.get());
컴파일 에러:
[bcc64 Error] Unit1.cpp(16): 'this' cannot be implicitly captured in this context
위와 같이 lambda expression 내부에서 capture가 필요없는 parameter의 property에 값을 쓸 경우 에러가 발생합니다.
암묵적 this capture에 대한 에러인데, 이 코드에서 this capture가 발생해야 할 이유를 모르겠습니다.
위와 같은 경우에는 Var->Add("Key=Value"); 로 바꾸면 this capture가 없어도 되긴 합니다만,
property의 값을 바꾸는 함수가 없을 경우 모두 구현해야해서 불편함이 생기네요.
|