Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-11-05


70. Is an array bound a nondeduced context?

Section:13.10.3.6  [temp.deduct.type]    Status:CD1    Submitter:Jack Rouse    Date:29 Sep 1998

[Moved to DR at 4/01 meeting.]

Paragraph 4 lists contexts in which template formals are not deduced.Were template formals in an expression in the array bound of an array typespecification intentionally left out of this list? Or was the intentthat such formals always be explicitly specified? Otherwise I believe thefollowing should be valid:

    template <int I> class IntArr {};    template <int I, int J>    void concat( int (&d)[I+J], const IntArr<I>& a, const IntArr<J>& b ) {}    int testing()    {        IntArr<2> a;        IntArr<3> b;        int d[5];        concat( d, a, b );    }
Can anybody shed some light on this?

From John Spicer:

Expressions involving nontype template parameters are nondeducedcontexts, even though they are omitted from the list in13.10.3.6 [temp.deduct.type] paragraph 4. See13.10.3.6 [temp.deduct.type]paragraphs12-14:

  1. A template type argument cannot be deduced from the type of a non-typetemplate-argument.

     ...

  1. If, in the declaration of a function template witha non-typetemplate-parameter, the non-typetemplate-parameteris used in an expression in the function parameter-list, the correspondingtemplate-argument must always be explicitly specified or deducedelsewhere because type deduction would otherwise alwaysfail for such atemplate-argument.

Proposed resolution (04/01): In13.10.3.6 [temp.deduct.type] paragraph 4, add athird bullet:




[8]ページ先頭

©2009-2025 Movatter.jp