fix: Explicitly pass lambda scope variables.

Default capture implicitly also capture *this, which would automatically be used if for example you referenced a method from the enclosing scope.
This commit is contained in:
Kirill Trofimov 2023-10-23 18:06:15 +03:00
parent c82066cf73
commit b205da16ef

View file

@ -84,29 +84,29 @@ protected:
{ } { }
Handler(std::vector<std::string> * dest) Handler(std::vector<std::string> * dest)
: fun([=](std::vector<std::string> ss) { *dest = ss; }) : fun([dest](std::vector<std::string> ss) { *dest = ss; })
, arity(ArityAny) , arity(ArityAny)
{ } { }
Handler(std::string * dest) Handler(std::string * dest)
: fun([=](std::vector<std::string> ss) { *dest = ss[0]; }) : fun([dest](std::vector<std::string> ss) { *dest = ss[0]; })
, arity(1) , arity(1)
{ } { }
Handler(std::optional<std::string> * dest) Handler(std::optional<std::string> * dest)
: fun([=](std::vector<std::string> ss) { *dest = ss[0]; }) : fun([dest](std::vector<std::string> ss) { *dest = ss[0]; })
, arity(1) , arity(1)
{ } { }
template<class T> template<class T>
Handler(T * dest, const T & val) Handler(T * dest, const T & val)
: fun([=](std::vector<std::string> ss) { *dest = val; }) : fun([dest, val](std::vector<std::string> ss) { *dest = val; })
, arity(0) , arity(0)
{ } { }
template<class I> template<class I>
Handler(I * dest) Handler(I * dest)
: fun([=](std::vector<std::string> ss) { : fun([dest](std::vector<std::string> ss) {
*dest = string2IntWithUnitPrefix<I>(ss[0]); *dest = string2IntWithUnitPrefix<I>(ss[0]);
}) })
, arity(1) , arity(1)
@ -114,7 +114,7 @@ protected:
template<class I> template<class I>
Handler(std::optional<I> * dest) Handler(std::optional<I> * dest)
: fun([=](std::vector<std::string> ss) { : fun([dest](std::vector<std::string> ss) {
*dest = string2IntWithUnitPrefix<I>(ss[0]); *dest = string2IntWithUnitPrefix<I>(ss[0]);
}) })
, arity(1) , arity(1)