【C++】template 統合スレ -- Part6 at TECH
[2ch|▼Menu]
736:デフォルトの名無しさん
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.


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5371日前に更新/262 KB
担当:undef