問題タブ [using-declaration]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - Q_ENUMS and using declarations do not work together
Consider the following class definition:
And the following main
file:
By doing this, I can easily access the named constants of my enum in QML.
As an example:
This works as long as the declaration of the enum is enclosed in the class.
As an example, if I change the class definition as shown below, it doesn't work anymore:
Now, Exported.BAR
in the QML file is undefined
.
The most basic question is: why it doesn't work with using declarations?
Note that it works with forwarded declarations, as an example:
This is true to the documentation of Q_ENUM
actually (emphasis mine):
This macro registers an enum type with the meta-object system. It must be placed after the enum declaration in a class that has the Q_OBJECT or the Q_GADGET macro.
No mentions of a definition in the whole section.
On the other side, we have this from the standard:
A using-declaration introduces a set of declarations into the declarative region in which the using-declaration appears.
So, I was expecting it to work as well. Anyway, this was maybe a wrong expectation on my side.
That said, any suggestion on how to deal with such an inconvenient?
The only way I can see to work around it in case the enum is defined out of the class is to define another enum within the class and have a one-to-one mapping between them.
It's far from being maintainable and a bit tedious indeed.
c++ - テンプレート宣言で重複したテンプレート引数を削除する方法
簡潔にするために、明示的なインスタンス化でテンプレート引数に 1 回だけ名前を付けたいと思いますが、コンパイラ エラーが発生します。の下の cppreference で説明されているように、C++ 構文を使用しようとしていますType alias, alias template
。ここに私のサンプルコードがあります:
ここで何が問題なのですか?
c++11 - forward_as_tuple を使用して従来の関数シグネチャにパラメーター パックを渡す
私のアプリでは、従来の関数シグネチャを介してパラメーター パックを渡し、値を変更したいと考えています。コメントとして私の試みで私の質問を示すコードは次のとおりです。
パラメータパックを宣言可能な左辺値にする方法はありますか?
c++ - 明示的なコンストラクターの継承 (インテル C++)
インテル C++ コンパイラ (バージョン 16.0.3.207 ビルド 20160415)は、基本クラスのコンストラクターがusingで継承されている場合、明示的な指定子をドロップするようです。これはバグですか?
c++ - using-declaration では、依存する名前はテンプレート置換後にコンストラクターにレンダリングできますか?
この例では:
T::X
X
のメンバーを参照する従属名ですT
。S<T>
でインスタンス化されている場合T = X
:
using 宣言は継承コンストラクタになりますか?
Clang はコードを拒否しますDEMOが、g++ はそれを受け入れます。
次のように書くと注意してください。
どちらのコンパイラもコードを受け入れ、継承コンストラクタとして扱います。using T::X
標準で継承コンストラクターになることは許可されていますか?