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

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

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

      1. 'using' 语句用 g++ 编译,用 clang 编译失败

        时间:2023-10-17

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

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

            • <bdo id='c5nBM'></bdo><ul id='c5nBM'></ul>
                    <tbody id='c5nBM'></tbody>
                1. <tfoot id='c5nBM'></tfoot>

                  本文介绍了'using' 语句用 g++ 编译,用 clang 编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下结构的代码(这当然在现实中要复杂得多,尤其是Base"是一个三行,但我试图抓住它的要点):

                  template A类{};模板B类{上市:B(){};};模板C类:公共B<A>>{上市:使用基数=B<A>>;使用 Base::B;};static const CC{};

                  代码通过 g++ 编译得很好

                  g++ -c test.cpp -std=c++11

                  但是,使用 clang++ 我收到一条我不太明白的错误消息

                  clang++ -c test.cpp -std=c++11

                  <块引用>

                  test.cpp:14:14: 错误:依赖使用声明解析为没有typename"的类型使用 Base::B;

                  我的代码有什么问题吗,或者这是 clang 中的一个错误?

                  注意:当使用 B<A<T>>::B; 编写 时,它可以用两个编译器很好地编译,但这不是我问题的真正解决方案.

                  clang 版本是 3.5.0,gcc 版本是 4.9.2

                  解决方案

                  这个案例已经在 C++ 委员会中讨论过(根据 Richard Smith https://llvm.org/bugs/show_bug.cgi?id=23107#c1) 现在事情变得更清楚了:

                  使用 Base::B

                  不是旨在成为有效代码.

                  下面的方法是引入类别名Base时正确表达构造函数继承的方式:

                  使用 Base::Base

                  然而,clang 产生的错误消息具有误导性,有望作为此错误报告的一部分得到解决(https://llvm.org/bugs/show_bug.cgi?id=22242).

                  I have code of the following structure (which is of course much more complex in reality, especially "Base" is a three-liner, but I've tried to capture the gist of it):

                  template <class T>
                  class A {};
                  
                  template <class T>
                  class B {
                  public:
                      B(){};
                  };
                  
                  template <class T>
                  class C : public B<A<T>> {
                  public:
                      using Base = B<A<T>>;
                      using Base::B;
                  };
                  
                  static const C<int> c{};
                  

                  The code compiles fine with g++ via

                  g++ -c test.cpp -std=c++11
                  

                  However, with clang++ I get an error message I don't really understand

                  clang++ -c test.cpp -std=c++11
                  

                  test.cpp:14:14: error: dependent using declaration resolved to type without 'typename' using Base::B;

                  Is there anything wrong with my code or is this a bug in clang?

                  Note: When writing using B<A<T>>::B; it compiles fine with both compilers, but this not a real solution to my problem.

                  Edit: clang version is 3.5.0, gcc version is 4.9.2

                  解决方案

                  This case has been discussed in the C++ committee (according to Richard Smith https://llvm.org/bugs/show_bug.cgi?id=23107#c1) and things have gotten clearer now:

                  using Base::B
                  

                  is not intended to be valid code.

                  The following method is the correct way to express constructor inheritance when introducing a class alias Base:

                  using Base::Base
                  

                  However, the error messages produced by clang are misleading and will hopefully be solved as part of this bug report (https://llvm.org/bugs/show_bug.cgi?id=22242).

                  这篇关于'using' 语句用 g++ 编译,用 clang 编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                2. <tfoot id='6W7eu'></tfoot>
                  • <small id='6W7eu'></small><noframes id='6W7eu'>

                        <bdo id='6W7eu'></bdo><ul id='6W7eu'></ul>

                          <legend id='6W7eu'><style id='6W7eu'><dir id='6W7eu'><q id='6W7eu'></q></dir></style></legend>

                            <tbody id='6W7eu'></tbody>

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