<legend id='Q80IZ'><style id='Q80IZ'><dir id='Q80IZ'><q id='Q80IZ'></q></dir></style></legend>
    <bdo id='Q80IZ'></bdo><ul id='Q80IZ'></ul>
<tfoot id='Q80IZ'></tfoot>
    1. <small id='Q80IZ'></small><noframes id='Q80IZ'>

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

        decltype 的行为

        时间:2023-07-02

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

          <legend id='0RhkA'><style id='0RhkA'><dir id='0RhkA'><q id='0RhkA'></q></dir></style></legend>
          • <bdo id='0RhkA'></bdo><ul id='0RhkA'></ul>
          • <tfoot id='0RhkA'></tfoot>

              <tbody id='0RhkA'></tbody>

            <small id='0RhkA'></small><noframes id='0RhkA'>

                  本文介绍了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 的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

                    <bdo id='4g0bV'></bdo><ul id='4g0bV'></ul>

                    1. <legend id='4g0bV'><style id='4g0bV'><dir id='4g0bV'><q id='4g0bV'></q></dir></style></legend>

                    2. <small id='4g0bV'></small><noframes id='4g0bV'>

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