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

      1. <tfoot id='pkGJB'></tfoot>
      2. <legend id='pkGJB'><style id='pkGJB'><dir id='pkGJB'><q id='pkGJB'></q></dir></style></legend>
          <bdo id='pkGJB'></bdo><ul id='pkGJB'></ul>
        <i id='pkGJB'><tr id='pkGJB'><dt id='pkGJB'><q id='pkGJB'><span id='pkGJB'><b id='pkGJB'><form id='pkGJB'><ins id='pkGJB'></ins><ul id='pkGJB'></ul><sub id='pkGJB'></sub></form><legend id='pkGJB'></legend><bdo id='pkGJB'><pre id='pkGJB'><center id='pkGJB'></center></pre></bdo></b><th id='pkGJB'></th></span></q></dt></tr></i><div id='pkGJB'><tfoot id='pkGJB'></tfoot><dl id='pkGJB'><fieldset id='pkGJB'></fieldset></dl></div>
      3. 不应该 decltype 触发其参数的编译吗?

        时间:2023-10-17
          <tbody id='8lZWD'></tbody>

      4. <small id='8lZWD'></small><noframes id='8lZWD'>

          • <legend id='8lZWD'><style id='8lZWD'><dir id='8lZWD'><q id='8lZWD'></q></dir></style></legend>

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

              <tfoot id='8lZWD'></tfoot>
                • <bdo id='8lZWD'></bdo><ul id='8lZWD'></ul>

                • 本文介绍了不应该 decltype 触发其参数的编译吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我很困惑这是如何工作的.鉴于:

                  So I'm perplexed as to how this works. Given:

                  template <typename T>
                  int foo(T t) { t.foo(); }
                  

                  这个调用似乎应该失败:

                  It seems like this call should fail:

                  decltype(foo(int{ 13 })) fail = 42;
                  
                  cout << fail << endl;
                  

                  取而代之的是它只是打印:

                  42

                  它在我可以访问的所有编译器上都是这样工作的.这是正确的行为吗?我向 C++ 标准请求报价.

                  It works this way on all the compilers I have access to. Is this correct behavior? I request a quote from the C++ Standard.

                  推荐答案

                  在 [dcl.spec] :

                  对于表达式e,decltype(e)表示的类型定义为如下:

                  For an expression e, the type denoted by decltype(e) is defined as follows:

                  如果 e 是一个无括号的 id 表达式,它命名从分解的标识符列表中引入的左值或引用声明,decltype(e) 是引用类型,如在分解声明的规范([dcl.decomp]);

                  if e is an unparenthesized id-expression naming an lvalue or reference introduced from the identifier-list of a decomposition declaration, decltype(e) is the referenced type as given in the specification of the decomposition declaration ([dcl.decomp]);

                  否则,如果 e 是无括号的 id 表达式或无括号的类成员访问 ([expr.ref]),则 decltype(e) 是e 命名的实体的类型.如果没有这样的实体,或者如果 e命名一组重载函数,程序格式错误;

                  otherwise, if e is an unparenthesized id-expression or an unparenthesized class member access ([expr.ref]), decltype(e) is the type of the entity named by e. If there is no such entity, or if e names a set of overloaded functions, the program is ill-formed;

                  否则,如果 e 是 xvalue,则 decltype(e) 是 T&&,其中 T 是 e 的类型;

                  otherwise, if e is an xvalue, decltype(e) is T&&, where T is the type of e;

                  否则,如果 e 是左值,则 decltype(e) 是 T&,其中 T 是 e 的类型;

                  otherwise, if e is an lvalue, decltype(e) is T&, where T is the type of e;

                  否则,decltype(e) 是 e 的类型.

                  otherwise, decltype(e) is the type of e.

                  decltype 说明符的操作数是未计算的操作数(条款[expr]).

                  The operand of the decltype specifier is an unevaluated operand (Clause [expr]).

                  (强调我的)

                  所以你的 foo(int{ 13 }) 永远不会被评估.

                  So your foo(int{ 13 }) is never evaluated.

                  这篇关于不应该 decltype 触发其参数的编译吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:'using' 语句用 g++ 编译,用 clang 编译失败 下一篇:MinGW 错误:不存在这样的文件或目录

                  相关文章

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

                  2. <small id='U727x'></small><noframes id='U727x'>

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