Capturing a lambda in another lambda can violate const qualifiersA const std::function wraps a non-const operator() / mutable lambdaC++ nested lambda bug in VS2010 with lambda parameter capture?C++ template allows discard of const reference qualifierPassing capturing lambda as function pointerlambdas: this capture ignores constness (vs std::bind)Why type const double is not captured by lambda from reaching-scope, but const int is?Non mutable lambda function: are copy-captured variables allowed to be const?GCC and Clang disagree about C++17 constexpr lambda capturesCapturing array of vectors in lambda makes elements constC++11 - lambda function pass vector in capture and modify itCopying object into lambda capture
Has a commercial or military jet bi-plane ever been manufactured?
Why do money exchangers give different rates to different bills?
Where can I go to avoid planes overhead?
Upside-Down Pyramid Addition...REVERSED!
Understanding trademark infringements in a world where many dictionary words are trademarks?
Pressure inside an infinite ocean?
I'm in your subnets, golfing your code
Why was the battle set up *outside* Winterfell?
What is the closest airport to the center of the city it serves?
Out of scope work duties and resignation
Can a nothic's Weird Insight action discover secrets about a player character that the character doesn't know about themselves?
Expressing 'our' for objects belonging to our apartment
What does this colon mean? It is not labeling, it is not ternary operator
What does a spell range of "25 ft. + 5 ft./2 levels" mean?
On which topic did Indiana Jones write his doctoral thesis?
What happens if you dump antimatter into a black hole?
Hyperlink on red background
Is there an idiom that support the idea that "inflation is bad"?
Why doesn't WotC use established keywords on all new cards?
Will 700 more planes a day fly because of the Heathrow expansion?
Are there any Final Fantasy Spirits in Super Smash Bros Ultimate?
How to model the curly cable part of the phone
Which module had more 'comfort' in terms of living space, the Lunar Module or the Command module?
What are the differences between credential stuffing and password spraying?
Capturing a lambda in another lambda can violate const qualifiers
A const std::function wraps a non-const operator() / mutable lambdaC++ nested lambda bug in VS2010 with lambda parameter capture?C++ template allows discard of const reference qualifierPassing capturing lambda as function pointerlambdas: this capture ignores constness (vs std::bind)Why type const double is not captured by lambda from reaching-scope, but const int is?Non mutable lambda function: are copy-captured variables allowed to be const?GCC and Clang disagree about C++17 constexpr lambda capturesCapturing array of vectors in lambda makes elements constC++11 - lambda function pass vector in capture and modify itCopying object into lambda capture
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Consider the following code:
int x = 3;
auto f1 = [x]() mutable
return x++;
;
auto f2 = [f1]()
return f1();
;
This will not compile, because f1()
is not const, and f2
is not declared as mutable. Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in? Notably, wrapping f1
in std::function
seems to resolve this problem (how?).
c++ lambda
add a comment |
Consider the following code:
int x = 3;
auto f1 = [x]() mutable
return x++;
;
auto f2 = [f1]()
return f1();
;
This will not compile, because f1()
is not const, and f2
is not declared as mutable. Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in? Notably, wrapping f1
in std::function
seems to resolve this problem (how?).
c++ lambda
1
As a side note, that's the case with most of the Rust's functions, where they explicitly acceptFnMut
(even though in case of e.g.fold
it would probably be called withFn
most of the time)
– Bartek Banachewicz
Apr 24 at 9:30
Possible duplicate of A const std::function wraps a non-const operator() / mutable lambda
– rustyx
Apr 24 at 10:01
@rustyx thanks, that answers the last point, but not the whole question.
– riv
Apr 24 at 10:36
2
A "lambda violating const qualifiers" sounds like something out of a sci-fi movie.
– LogicalBranch
Apr 24 at 17:21
add a comment |
Consider the following code:
int x = 3;
auto f1 = [x]() mutable
return x++;
;
auto f2 = [f1]()
return f1();
;
This will not compile, because f1()
is not const, and f2
is not declared as mutable. Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in? Notably, wrapping f1
in std::function
seems to resolve this problem (how?).
c++ lambda
Consider the following code:
int x = 3;
auto f1 = [x]() mutable
return x++;
;
auto f2 = [f1]()
return f1();
;
This will not compile, because f1()
is not const, and f2
is not declared as mutable. Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in? Notably, wrapping f1
in std::function
seems to resolve this problem (how?).
c++ lambda
c++ lambda
asked Apr 24 at 9:20
rivriv
3,68011533
3,68011533
1
As a side note, that's the case with most of the Rust's functions, where they explicitly acceptFnMut
(even though in case of e.g.fold
it would probably be called withFn
most of the time)
– Bartek Banachewicz
Apr 24 at 9:30
Possible duplicate of A const std::function wraps a non-const operator() / mutable lambda
– rustyx
Apr 24 at 10:01
@rustyx thanks, that answers the last point, but not the whole question.
– riv
Apr 24 at 10:36
2
A "lambda violating const qualifiers" sounds like something out of a sci-fi movie.
– LogicalBranch
Apr 24 at 17:21
add a comment |
1
As a side note, that's the case with most of the Rust's functions, where they explicitly acceptFnMut
(even though in case of e.g.fold
it would probably be called withFn
most of the time)
– Bartek Banachewicz
Apr 24 at 9:30
Possible duplicate of A const std::function wraps a non-const operator() / mutable lambda
– rustyx
Apr 24 at 10:01
@rustyx thanks, that answers the last point, but not the whole question.
– riv
Apr 24 at 10:36
2
A "lambda violating const qualifiers" sounds like something out of a sci-fi movie.
– LogicalBranch
Apr 24 at 17:21
1
1
As a side note, that's the case with most of the Rust's functions, where they explicitly accept
FnMut
(even though in case of e.g. fold
it would probably be called with Fn
most of the time)– Bartek Banachewicz
Apr 24 at 9:30
As a side note, that's the case with most of the Rust's functions, where they explicitly accept
FnMut
(even though in case of e.g. fold
it would probably be called with Fn
most of the time)– Bartek Banachewicz
Apr 24 at 9:30
Possible duplicate of A const std::function wraps a non-const operator() / mutable lambda
– rustyx
Apr 24 at 10:01
Possible duplicate of A const std::function wraps a non-const operator() / mutable lambda
– rustyx
Apr 24 at 10:01
@rustyx thanks, that answers the last point, but not the whole question.
– riv
Apr 24 at 10:36
@rustyx thanks, that answers the last point, but not the whole question.
– riv
Apr 24 at 10:36
2
2
A "lambda violating const qualifiers" sounds like something out of a sci-fi movie.
– LogicalBranch
Apr 24 at 17:21
A "lambda violating const qualifiers" sounds like something out of a sci-fi movie.
– LogicalBranch
Apr 24 at 17:21
add a comment |
2 Answers
2
active
oldest
votes
Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in?
That's a design decision for your library API. You can require client code to pass function objects with a const
-qualified operator()
(which is the case for non-mutable
lambda expressions). If something different is passed, a compiler error is triggered. But if the context might require a function object argument that modifies its state, then yes, you have to make the internal lambda mutable
.
An alternative would be to dispatch on the ability to invoke operator()
on a const
-qualified instance of the given function type. Something along those lines (note that this needs a fix for function objects with both const
and non-const
operator()
, which results in an ambiguity):
template <class Fct>
auto wrap(Fct&& f) -> decltype(f(), void())
[fct = std::forward<Fct>(f)]() mutable fct(); ();
template <class Fct>
auto wrap(Fct&& f) -> decltype(std::declval<const Fct&>()(), void())
[fct = std::forward<Fct>(f)]() fct(); ();
Notably, wrapping f1 in std::function seems to resolve this problem (how?).
This is a bug in std::function
due to its type-erasure and copy semantics. It allows non-const
-qualified operator()
to be invoked, which can be verified with such a snippet:
const std::function<void()> f = [i = 0]() mutable ++i; ;
f(); // Shouldn't be possible, but unfortunately, it is
This is a known issue, it's worth checking out Titus Winter's complaint on this.
add a comment |
I'll start by addressing your second question first. std::function
type erases, and holds a copy of the functor it's initialized with. That means there's a layer of indirection between std::function::operator()
and the actual functor's operator()
.
Envision if you will, holding something in your class by pointer. Then you may call a mutating operation on the pointee from a const member function of your class, because it doesn't affect (in a shallow view) the pointer that the class holds. This is a similar situation to what you observed.
As for your first question... "Always" is too strong a word. It depends on your goal.
If you want to support self mutating functors easily, then you should capture in a mutable lambda. But beware it may affect the library functions you may call now.
If you wish to favor non-mutating operations, then a non-mutable lambda. I say "favor" because as we observed, the type system can be "fooled" with an extra level of indirection. So the approach you prefer is only going to be easier to use, not impossible to go around. This is as the sage advice goes, make correct use of your API easy, and incorrect harder.
1
Notably, wrapping a passed lambda instd::ref
provides the level of indirection that allows mutability even inconst
contexts. It also gets around the "functors may be copied around in the implementation" if you are after tracking some state.
– Max Langhof
Apr 24 at 9:47
Ah, I see it became a hot network post.
– StoryTeller
Apr 24 at 10:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55826592%2fcapturing-a-lambda-in-another-lambda-can-violate-const-qualifiers%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in?
That's a design decision for your library API. You can require client code to pass function objects with a const
-qualified operator()
(which is the case for non-mutable
lambda expressions). If something different is passed, a compiler error is triggered. But if the context might require a function object argument that modifies its state, then yes, you have to make the internal lambda mutable
.
An alternative would be to dispatch on the ability to invoke operator()
on a const
-qualified instance of the given function type. Something along those lines (note that this needs a fix for function objects with both const
and non-const
operator()
, which results in an ambiguity):
template <class Fct>
auto wrap(Fct&& f) -> decltype(f(), void())
[fct = std::forward<Fct>(f)]() mutable fct(); ();
template <class Fct>
auto wrap(Fct&& f) -> decltype(std::declval<const Fct&>()(), void())
[fct = std::forward<Fct>(f)]() fct(); ();
Notably, wrapping f1 in std::function seems to resolve this problem (how?).
This is a bug in std::function
due to its type-erasure and copy semantics. It allows non-const
-qualified operator()
to be invoked, which can be verified with such a snippet:
const std::function<void()> f = [i = 0]() mutable ++i; ;
f(); // Shouldn't be possible, but unfortunately, it is
This is a known issue, it's worth checking out Titus Winter's complaint on this.
add a comment |
Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in?
That's a design decision for your library API. You can require client code to pass function objects with a const
-qualified operator()
(which is the case for non-mutable
lambda expressions). If something different is passed, a compiler error is triggered. But if the context might require a function object argument that modifies its state, then yes, you have to make the internal lambda mutable
.
An alternative would be to dispatch on the ability to invoke operator()
on a const
-qualified instance of the given function type. Something along those lines (note that this needs a fix for function objects with both const
and non-const
operator()
, which results in an ambiguity):
template <class Fct>
auto wrap(Fct&& f) -> decltype(f(), void())
[fct = std::forward<Fct>(f)]() mutable fct(); ();
template <class Fct>
auto wrap(Fct&& f) -> decltype(std::declval<const Fct&>()(), void())
[fct = std::forward<Fct>(f)]() fct(); ();
Notably, wrapping f1 in std::function seems to resolve this problem (how?).
This is a bug in std::function
due to its type-erasure and copy semantics. It allows non-const
-qualified operator()
to be invoked, which can be verified with such a snippet:
const std::function<void()> f = [i = 0]() mutable ++i; ;
f(); // Shouldn't be possible, but unfortunately, it is
This is a known issue, it's worth checking out Titus Winter's complaint on this.
add a comment |
Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in?
That's a design decision for your library API. You can require client code to pass function objects with a const
-qualified operator()
(which is the case for non-mutable
lambda expressions). If something different is passed, a compiler error is triggered. But if the context might require a function object argument that modifies its state, then yes, you have to make the internal lambda mutable
.
An alternative would be to dispatch on the ability to invoke operator()
on a const
-qualified instance of the given function type. Something along those lines (note that this needs a fix for function objects with both const
and non-const
operator()
, which results in an ambiguity):
template <class Fct>
auto wrap(Fct&& f) -> decltype(f(), void())
[fct = std::forward<Fct>(f)]() mutable fct(); ();
template <class Fct>
auto wrap(Fct&& f) -> decltype(std::declval<const Fct&>()(), void())
[fct = std::forward<Fct>(f)]() fct(); ();
Notably, wrapping f1 in std::function seems to resolve this problem (how?).
This is a bug in std::function
due to its type-erasure and copy semantics. It allows non-const
-qualified operator()
to be invoked, which can be verified with such a snippet:
const std::function<void()> f = [i = 0]() mutable ++i; ;
f(); // Shouldn't be possible, but unfortunately, it is
This is a known issue, it's worth checking out Titus Winter's complaint on this.
Does this mean that if I have a library function that accepts an arbitrary function argument and captures it in a lambda, I always need to make that lambda mutable, because I don't know what users can pass in?
That's a design decision for your library API. You can require client code to pass function objects with a const
-qualified operator()
(which is the case for non-mutable
lambda expressions). If something different is passed, a compiler error is triggered. But if the context might require a function object argument that modifies its state, then yes, you have to make the internal lambda mutable
.
An alternative would be to dispatch on the ability to invoke operator()
on a const
-qualified instance of the given function type. Something along those lines (note that this needs a fix for function objects with both const
and non-const
operator()
, which results in an ambiguity):
template <class Fct>
auto wrap(Fct&& f) -> decltype(f(), void())
[fct = std::forward<Fct>(f)]() mutable fct(); ();
template <class Fct>
auto wrap(Fct&& f) -> decltype(std::declval<const Fct&>()(), void())
[fct = std::forward<Fct>(f)]() fct(); ();
Notably, wrapping f1 in std::function seems to resolve this problem (how?).
This is a bug in std::function
due to its type-erasure and copy semantics. It allows non-const
-qualified operator()
to be invoked, which can be verified with such a snippet:
const std::function<void()> f = [i = 0]() mutable ++i; ;
f(); // Shouldn't be possible, but unfortunately, it is
This is a known issue, it's worth checking out Titus Winter's complaint on this.
edited Apr 24 at 10:11
answered Apr 24 at 9:30
lubgrlubgr
16.7k32558
16.7k32558
add a comment |
add a comment |
I'll start by addressing your second question first. std::function
type erases, and holds a copy of the functor it's initialized with. That means there's a layer of indirection between std::function::operator()
and the actual functor's operator()
.
Envision if you will, holding something in your class by pointer. Then you may call a mutating operation on the pointee from a const member function of your class, because it doesn't affect (in a shallow view) the pointer that the class holds. This is a similar situation to what you observed.
As for your first question... "Always" is too strong a word. It depends on your goal.
If you want to support self mutating functors easily, then you should capture in a mutable lambda. But beware it may affect the library functions you may call now.
If you wish to favor non-mutating operations, then a non-mutable lambda. I say "favor" because as we observed, the type system can be "fooled" with an extra level of indirection. So the approach you prefer is only going to be easier to use, not impossible to go around. This is as the sage advice goes, make correct use of your API easy, and incorrect harder.
1
Notably, wrapping a passed lambda instd::ref
provides the level of indirection that allows mutability even inconst
contexts. It also gets around the "functors may be copied around in the implementation" if you are after tracking some state.
– Max Langhof
Apr 24 at 9:47
Ah, I see it became a hot network post.
– StoryTeller
Apr 24 at 10:03
add a comment |
I'll start by addressing your second question first. std::function
type erases, and holds a copy of the functor it's initialized with. That means there's a layer of indirection between std::function::operator()
and the actual functor's operator()
.
Envision if you will, holding something in your class by pointer. Then you may call a mutating operation on the pointee from a const member function of your class, because it doesn't affect (in a shallow view) the pointer that the class holds. This is a similar situation to what you observed.
As for your first question... "Always" is too strong a word. It depends on your goal.
If you want to support self mutating functors easily, then you should capture in a mutable lambda. But beware it may affect the library functions you may call now.
If you wish to favor non-mutating operations, then a non-mutable lambda. I say "favor" because as we observed, the type system can be "fooled" with an extra level of indirection. So the approach you prefer is only going to be easier to use, not impossible to go around. This is as the sage advice goes, make correct use of your API easy, and incorrect harder.
1
Notably, wrapping a passed lambda instd::ref
provides the level of indirection that allows mutability even inconst
contexts. It also gets around the "functors may be copied around in the implementation" if you are after tracking some state.
– Max Langhof
Apr 24 at 9:47
Ah, I see it became a hot network post.
– StoryTeller
Apr 24 at 10:03
add a comment |
I'll start by addressing your second question first. std::function
type erases, and holds a copy of the functor it's initialized with. That means there's a layer of indirection between std::function::operator()
and the actual functor's operator()
.
Envision if you will, holding something in your class by pointer. Then you may call a mutating operation on the pointee from a const member function of your class, because it doesn't affect (in a shallow view) the pointer that the class holds. This is a similar situation to what you observed.
As for your first question... "Always" is too strong a word. It depends on your goal.
If you want to support self mutating functors easily, then you should capture in a mutable lambda. But beware it may affect the library functions you may call now.
If you wish to favor non-mutating operations, then a non-mutable lambda. I say "favor" because as we observed, the type system can be "fooled" with an extra level of indirection. So the approach you prefer is only going to be easier to use, not impossible to go around. This is as the sage advice goes, make correct use of your API easy, and incorrect harder.
I'll start by addressing your second question first. std::function
type erases, and holds a copy of the functor it's initialized with. That means there's a layer of indirection between std::function::operator()
and the actual functor's operator()
.
Envision if you will, holding something in your class by pointer. Then you may call a mutating operation on the pointee from a const member function of your class, because it doesn't affect (in a shallow view) the pointer that the class holds. This is a similar situation to what you observed.
As for your first question... "Always" is too strong a word. It depends on your goal.
If you want to support self mutating functors easily, then you should capture in a mutable lambda. But beware it may affect the library functions you may call now.
If you wish to favor non-mutating operations, then a non-mutable lambda. I say "favor" because as we observed, the type system can be "fooled" with an extra level of indirection. So the approach you prefer is only going to be easier to use, not impossible to go around. This is as the sage advice goes, make correct use of your API easy, and incorrect harder.
answered Apr 24 at 9:32
StoryTellerStoryTeller
107k15225288
107k15225288
1
Notably, wrapping a passed lambda instd::ref
provides the level of indirection that allows mutability even inconst
contexts. It also gets around the "functors may be copied around in the implementation" if you are after tracking some state.
– Max Langhof
Apr 24 at 9:47
Ah, I see it became a hot network post.
– StoryTeller
Apr 24 at 10:03
add a comment |
1
Notably, wrapping a passed lambda instd::ref
provides the level of indirection that allows mutability even inconst
contexts. It also gets around the "functors may be copied around in the implementation" if you are after tracking some state.
– Max Langhof
Apr 24 at 9:47
Ah, I see it became a hot network post.
– StoryTeller
Apr 24 at 10:03
1
1
Notably, wrapping a passed lambda in
std::ref
provides the level of indirection that allows mutability even in const
contexts. It also gets around the "functors may be copied around in the implementation" if you are after tracking some state.– Max Langhof
Apr 24 at 9:47
Notably, wrapping a passed lambda in
std::ref
provides the level of indirection that allows mutability even in const
contexts. It also gets around the "functors may be copied around in the implementation" if you are after tracking some state.– Max Langhof
Apr 24 at 9:47
Ah, I see it became a hot network post.
– StoryTeller
Apr 24 at 10:03
Ah, I see it became a hot network post.
– StoryTeller
Apr 24 at 10:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55826592%2fcapturing-a-lambda-in-another-lambda-can-violate-const-qualifiers%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
As a side note, that's the case with most of the Rust's functions, where they explicitly accept
FnMut
(even though in case of e.g.fold
it would probably be called withFn
most of the time)– Bartek Banachewicz
Apr 24 at 9:30
Possible duplicate of A const std::function wraps a non-const operator() / mutable lambda
– rustyx
Apr 24 at 10:01
@rustyx thanks, that answers the last point, but not the whole question.
– riv
Apr 24 at 10:36
2
A "lambda violating const qualifiers" sounds like something out of a sci-fi movie.
– LogicalBranch
Apr 24 at 17:21