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

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

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

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

        为什么 C++ 不能从赋值推导出模板类型?

        时间:2024-08-14
        <i id='4xBc4'><tr id='4xBc4'><dt id='4xBc4'><q id='4xBc4'><span id='4xBc4'><b id='4xBc4'><form id='4xBc4'><ins id='4xBc4'></ins><ul id='4xBc4'></ul><sub id='4xBc4'></sub></form><legend id='4xBc4'></legend><bdo id='4xBc4'><pre id='4xBc4'><center id='4xBc4'></center></pre></bdo></b><th id='4xBc4'></th></span></q></dt></tr></i><div id='4xBc4'><tfoot id='4xBc4'></tfoot><dl id='4xBc4'><fieldset id='4xBc4'></fieldset></dl></div>

          <tbody id='4xBc4'></tbody>

          <bdo id='4xBc4'></bdo><ul id='4xBc4'></ul>
        • <legend id='4xBc4'><style id='4xBc4'><dir id='4xBc4'><q id='4xBc4'></q></dir></style></legend>

              • <tfoot id='4xBc4'></tfoot>

                <small id='4xBc4'></small><noframes id='4xBc4'>

                  本文介绍了为什么 C++ 不能从赋值推导出模板类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  int x = fromString("test") :无法推导出ValueType"的模板参数

                  int x = fromString("test") :按预期工作正常

                  那么为什么编译器会在这里挣扎?我在各种真实的模板函数中看到它,而不仅仅是这个愚蠢的例子.它必须是语言的一个特性,但是什么?

                  So why does the compiler struggle here? I see it with all kinds of real template functions, not just this silly example. It must be a feature of the language, but what?

                  推荐答案

                  C++ 不对返回值进行类型推断.即,它被分配给 int 的事实不用于模板参数推导.

                  C++ doesn't do type inference on the return value. I.e., the fact that it is being assigned to an int isn't used in template parameter deduction.

                  (删除了编辑,因为其他人已经提供了超载的演员解决方案.)

                  (Removed edit, since someone else presented the overloaded cast solution already.)

                  这篇关于为什么 C++ 不能从赋值推导出模板类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:std::lower_bound 不专门用于红黑树迭代器是否有任何技术原因? 下一篇:从 C++ (STL) 中的(它的)迭代器类型获取容器类型

                  相关文章

                1. <small id='nlKmn'></small><noframes id='nlKmn'>

                  • <bdo id='nlKmn'></bdo><ul id='nlKmn'></ul>

                    <legend id='nlKmn'><style id='nlKmn'><dir id='nlKmn'><q id='nlKmn'></q></dir></style></legend>

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