Code: class B {} class D : B {} template foo(S, T : S) { } // doesn't work // template foo(S, T : B) { } // this works for some reason alias foo!(B, D) bar; Compiler output: bug.d(7): template instance foo!(B,D) does not match any template declaration ---- I'm guessing here what should happen: From http://www.digitalmars.com/d/template.html, Argument deduction: The types of template parameters are deduced for a particular template instantiation by comparing the template argument with the corresponding template parameter. For each template parameter, the following rules are applied in order until a type is deduced for each parameter: 1. If there is no type specialization for the parameter, the type of the parameter is set to the template argument. (S, T : S) -> (B, T : S) 2. If the type specialization is dependent on a type parameter, the type of that parameter is set to be the corresponding part of the type argument. (B, T : S) -> (B, T : B) 3. If after all the type arguments are examined there are any type parameters left with no type assigned, they are assigned types corresponding to the template argument in the same position in the TemplateArgumentList. (B, T : B) -> (B, D) 4. If applying the above rules does not result in exactly one type for each template parameter, then it is an error. ok?
Fixed DMD 1.018 and DMD 2.002
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル