元の回答はFoo<Bar>
でした。私は実際には今は整形式だと思っています。しかし、最終的に、clangバグに基づいています。
私は実際にもFoo<Bar>
が悪い形成されていると思います。
A template-argument matches a template template-parameterP
when P
is at least as specialized as the template-argumentA
:
A template template-parameterP
is at least as specialized as a template template-argumentA
if, given the following rewrite to two function templates, the function template corresponding to P
is at least as specialized as the function template corresponding to A
according to the partial ordering rules for function templates ([temp.func.order]). Given an invented class template X
with the template parameter list of A
(including default arguments):
- Each of the two function templates has the same template parameters, respectively, as
P
or A
.
- Each function template has a single function parameter whose type is a specialization of
X
with template arguments corresponding to the template parameters from the respective function template where, for each template parameter PP
in the template parameter list of the function template, a corresponding template argument AA
is formed. If PP
declares a parameter pack, then AA
is the pack expansion PP...
([temp.variadic]); otherwise, AA
is the id-expressionPP
.
If the rewrite produces an invalid type, then P
is not at least as specialized as A
.
がFoo<Bar>
自体は大丈夫であるかどうかを検証することを意味し、我々は合成:
template <decltype(auto) I> struct X;
template <auto I> void __f(X<I>); // P
template <decltype(auto) I> void __f(X<I>); // A
すべての種類P0522次新ルールは、ということですここでは有効です(最後のステートメントは適用されません)。ここで、通常、部分的な順序付けを行うときは、オーバーロードの解決またはクラステンプレートの特殊化の選択のコンテキストになります。この場合、F
はF
がの場合、F
がmore specialized thanG
の場合は、ファンクションテンプレート"more specialized"です。 G
とG
は少なくともF
と同じく特化していません。
しかし、この文脈では、私たちはどちらがより専門的であるか気にしません。我々はP
が少なくともA
と専門化されていればよい。つまり、控除額はA
からP
に引き上げられなければなりません。だから、もしある値V
を持つユニークなタイプU
を合成すると、X<I>
はX<V>
から推測できますか?はい。したがって、P
は少なくともA
として特化されているので、テンプレート引数Bar
はテンプレートパラメータTT
と一致します。
ここで、この点を過ぎて、私はこれをクランバグといいます。テンプレートテンプレートパラメータはtemplate <auto>
です。これは、式の検証に使用するものです。非タイプのテンプレートパラメータauto
を使用すると、x
を値として使用しようとしますが、x
は有効な定数式ではないため、これは失敗します。clangはtemplate <decltype(auto) >
を直接使用しているようです - これはわかりませんが、有効です。
しかし、私はこの事件が考慮されているかどうかはわかりません - 私はどちらかの言い方を見ないし、問題を提起する価値があると言います。
テンプレートパラメータに '(x)'を指定する方法はわかりません。ここで 'x'は変数ですが、どの種類のテンプレートでも有効です。私が最後にチェックしたのは、テンプレートパラメータは型または定数だけでした。 –
@SamVarshavchik 'decltype(auto)'の場合、変数にはもちろんリンクがある限り(これが実際に有効であることを確認した最後の時間)変数を参照するように解決されます) –
これは、 。 –