2

Here is the question I asked: How to capture a single class data member in a lambda expression?. However I don't understand why it was marked as a duplicate of C++11 lambdas: member variable capture gotcha.

I understand the other question but I fail to see how it serves as an answer to my question.

Can someone please enlighten me or perhaps confirm my suspicion that it was closed incorrectly?

1 Answer 1

3

It appears that the answer to the dupe target is the answer to your question:

Yes. Capturing member variables is always done via capturing this; it is the only way to access a member variable.

The questions have the same answer, so an answer saying:

No, you can't, see this other question

Isn't useful, and it was closed as a dupe of that question.

Update:

It appears that the correct answer has changed since the duplicate was posted. In some ways, it's still a duplicate because the other answer could/should be updated to include this information. That said, due to your questions more specific scope, I have voted to reopen.

6
  • I understand that logic but my question is about capturing a single member via this instead of all of them. Furthermore, from the answers I received it appears the answer Yes, it's possible but you need C++14 features. So isn't that a different and valid answer? Jun 4, 2015 at 21:57
  • @JamesAdkison If I had noticed that, I would agree :). I can see why the original dupe flags were cast if they weren't carefully reading the existing answers though. Jun 4, 2015 at 22:01
  • This is new territory for me. So should I make an edit to my question stating why I think it's different than the other question? Jun 4, 2015 at 22:09
  • 2
    @JamesAdkison Yes, making a comment/edit noting that the answer can/is different than the dupe due to the scope would be appropriate. Just keep it civil :) Jun 4, 2015 at 22:10
  • Kate Gregory outlines the correct procedure on Meta.SE, @JamesAdkison.
    – jscs
    Jun 5, 2015 at 0:00
  • @JoshCaswell Thanks for the link. That makes a lot of sense and makes the question much less awkward (especially in the event it gets reopened). I'll update my question in this manner. Jun 5, 2015 at 1:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .