<small id='onDsY'></small><noframes id='onDsY'>

      <legend id='onDsY'><style id='onDsY'><dir id='onDsY'><q id='onDsY'></q></dir></style></legend>
        <tfoot id='onDsY'></tfoot>
          <bdo id='onDsY'></bdo><ul id='onDsY'></ul>

      1. <i id='onDsY'><tr id='onDsY'><dt id='onDsY'><q id='onDsY'><span id='onDsY'><b id='onDsY'><form id='onDsY'><ins id='onDsY'></ins><ul id='onDsY'></ul><sub id='onDsY'></sub></form><legend id='onDsY'></legend><bdo id='onDsY'><pre id='onDsY'><center id='onDsY'></center></pre></bdo></b><th id='onDsY'></th></span></q></dt></tr></i><div id='onDsY'><tfoot id='onDsY'></tfoot><dl id='onDsY'><fieldset id='onDsY'></fieldset></dl></div>

        C++0x lambda 按值捕获总是常量?

        C++0x lambda capture by value always const?(C++0x lambda 按值捕获总是常量?)
        <tfoot id='DTyXO'></tfoot>
        • <legend id='DTyXO'><style id='DTyXO'><dir id='DTyXO'><q id='DTyXO'></q></dir></style></legend>
          <i id='DTyXO'><tr id='DTyXO'><dt id='DTyXO'><q id='DTyXO'><span id='DTyXO'><b id='DTyXO'><form id='DTyXO'><ins id='DTyXO'></ins><ul id='DTyXO'></ul><sub id='DTyXO'></sub></form><legend id='DTyXO'></legend><bdo id='DTyXO'><pre id='DTyXO'><center id='DTyXO'></center></pre></bdo></b><th id='DTyXO'></th></span></q></dt></tr></i><div id='DTyXO'><tfoot id='DTyXO'></tfoot><dl id='DTyXO'><fieldset id='DTyXO'></fieldset></dl></div>

                <tbody id='DTyXO'></tbody>
                <bdo id='DTyXO'></bdo><ul id='DTyXO'></ul>

                  <small id='DTyXO'></small><noframes id='DTyXO'>

                  本文介绍了C++0x lambda 按值捕获总是常量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法按值捕获,并使捕获的值非常量?我有一个库仿函数,我想捕获 &调用一个非常量但应该是的方法.

                  Is there any way to capture by value, and make the captured value non-const? I have a library functor that I would like to capture & call a method that is non-const but should be.

                  以下内容不能编译,但使 foo::operator() const 修复它.

                  The following doesn't compile but making foo::operator() const fixes it.

                  struct foo
                  {
                    bool operator () ( const bool & a )
                    {
                      return a;
                    }
                  };
                  
                  
                  int _tmain(int argc, _TCHAR* argv[])
                  {
                    foo afoo;
                  
                    auto bar = [=] () -> bool
                      {
                        afoo(true);
                      };
                  
                    return 0;
                  }
                  

                  推荐答案

                  使用可变的.

                  
                  auto bar = [=] () mutable -> bool ....
                  

                  如果没有 mutable,您将声明 lambda 对象的运算符 () const.

                  Without mutable you are declaring the operator () of the lambda object const.

                  这篇关于C++0x lambda 按值捕获总是常量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to print vector#39;s data(如何打印矢量的数据)
                  Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                  How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                  MSVC++ warning flags(MSVC++ 警告标志)
                  How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                  stack overflow error in C++ program(C++程序中的堆栈溢出错误)
                    <tbody id='8a8CP'></tbody>
                • <legend id='8a8CP'><style id='8a8CP'><dir id='8a8CP'><q id='8a8CP'></q></dir></style></legend>
                    <bdo id='8a8CP'></bdo><ul id='8a8CP'></ul>

                          <small id='8a8CP'></small><noframes id='8a8CP'>

                          <i id='8a8CP'><tr id='8a8CP'><dt id='8a8CP'><q id='8a8CP'><span id='8a8CP'><b id='8a8CP'><form id='8a8CP'><ins id='8a8CP'></ins><ul id='8a8CP'></ul><sub id='8a8CP'></sub></form><legend id='8a8CP'></legend><bdo id='8a8CP'><pre id='8a8CP'><center id='8a8CP'></center></pre></bdo></b><th id='8a8CP'></th></span></q></dt></tr></i><div id='8a8CP'><tfoot id='8a8CP'></tfoot><dl id='8a8CP'><fieldset id='8a8CP'></fieldset></dl></div>
                        • <tfoot id='8a8CP'></tfoot>