Capturing reference variable by copy in C++0x lambda

前端 未结 2 1903
迷失自我
迷失自我 2020-12-15 15:50

According to the answers and comments for this question, when a reference variable is captured by value, the lambda object should make a copy of the referenced object, not t

相关标签:
2条回答
  • 2020-12-15 16:43

    This has just been fixed in gcc-4.7 trunk and gcc-4.6 branch. These should be available in gcc-4.7.0 (a while from now - still in stage 1) and gcc-4.6.2 (alas 4.6.1 just came out.)

    But the intrepid could wait for the next snapshots or get a subversion copy.

    See audit trail for details.

    0 讨论(0)
  • 2020-12-15 16:46

    Compiled with VS 2010 gives:

    value capture
    i: 10
    ir: 10
    &i: 0012FE74
    &ir: 0012FE78
    
    reference capture
    i: 10
    ir: 10
    &i: 0012FF60
    &ir: 0012FF60
    

    Looks like a bug for me.

    0 讨论(0)
提交回复
热议问题