<bdo id='uNJ1e'></bdo><ul id='uNJ1e'></ul>

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

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

        decltype 的行为

        时间:2023-10-06

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

              <tfoot id='WuVIL'></tfoot>

              • <small id='WuVIL'></small><noframes id='WuVIL'>

              • <i id='WuVIL'><tr id='WuVIL'><dt id='WuVIL'><q id='WuVIL'><span id='WuVIL'><b id='WuVIL'><form id='WuVIL'><ins id='WuVIL'></ins><ul id='WuVIL'></ul><sub id='WuVIL'></sub></form><legend id='WuVIL'></legend><bdo id='WuVIL'><pre id='WuVIL'><center id='WuVIL'></center></pre></bdo></b><th id='WuVIL'></th></span></q></dt></tr></i><div id='WuVIL'><tfoot id='WuVIL'></tfoot><dl id='WuVIL'><fieldset id='WuVIL'></fieldset></dl></div>
                  <tbody id='WuVIL'></tbody>
                  本文介绍了decltype 的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  假设我有一些 stl 容器类 obj 的对象.我可以通过这种方式定义其他相同类型的对象:

                  decltype(obj) obj2;

                  但我不能以这种方式为容器声明迭代器:

                  decltype(obj)::iterator it = obj.begin();

                  为什么?我做错了什么吗?

                  解决方案

                  根据最终的 C++0x 草案 (FDIS),您的代码格式良好.这是 Visual Studio 编译器尚未实现的后期更改.

                  与此同时,一种解决方法是使用 typedef:

                  typedef decltype(obj) obj_type;obj_type::iterator it = obj.begin();

                  相关章节和诗句是5.1.1/8:

                  <前>合格 ID:[...]nested-name-specifier 模板opt unqualified-id嵌套名称说明符:[...]声明类型说明符 ::声明类型说明符:decltype ( 表达式 )

                  为了完整起见:

                  原始核心问题

                  措辞建议

                  Say I have an object of some of stl container classes obj. I can define other object of same type this way:

                  decltype(obj) obj2;
                  

                  But I can't declare iterator for the container this way:

                  decltype(obj)::iterator it = obj.begin();
                  

                  Why? Am I doing something wrong?

                  解决方案

                  Your code is well-formed according to the final C++0x draft (FDIS). This was a late change that's not yet been implemented by the Visual Studio compiler.

                  In the meantime, a workaround is to use a typedef:

                  typedef decltype(obj) obj_type;
                  obj_type::iterator it = obj.begin();
                  

                  EDIT: The relevant chapter and verse is 5.1.1/8:

                  qualified-id:
                      [...]
                      nested-name-specifier templateopt unqualified-id
                  
                  nested-name-specifier:
                      [...]
                      decltype-specifier ::
                  
                  decltype-specifier:
                      decltype ( expression )
                  

                  And for completeness's sake:

                  The original core issue

                  Proposal for wording

                  这篇关于decltype 的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在调试模式下找不到 msvcr90d.dll 下一篇:Visual Studio C++ 2005-2013 中的智能感知中缺少函数定

                  相关文章

                  最新文章

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

                    <bdo id='uElzk'></bdo><ul id='uElzk'></ul>

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

                  1. <tfoot id='uElzk'></tfoot>