05/07/10 00:59:18
実は初めてこの構文を知ったんだけどさ
>URLリンク(www.comeaucomputing.com)
>
>template <class T>
>T foo(T blah)
>{
> xyz object;
> T someInt;
>
>// (略)
>
> someInt = object.mt<int>(99.99); // AA: ill-formed
> someInt = object.template mt<int>(99.99); // BB: well-formed
>
> return someInt;
>}
ってなってて AA は ill-formed になってるんだけど、 object はテンプレートパラメータに依存してないんだから
template をつけなくても問題ないと思うんだけど。実際 g++ 3.4.4 だと通るし、. の前をテンプレートパラメータに
依存するように書き換えるとエラーが出る。
規格参照箇所 14.2-4
> When the name of a member template specialization appears after . or -> in a postfix-expression, or after
> nested-name-specifier in a qualified-id, and the postfix-expression or qualified-id explicitly depends on a
> template-parameter (14.6.2), the member template name must be prefixed by the keyword template.
> Otherwise the name is assumed to name a non-template.