Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


1186. Non-dependentconstexpr violations in function templates

Section:9.2.6  [dcl.constexpr]    Status:C++11    Submitter:Jason Merrill    Date:2010-08-30

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

9.2.6 [dcl.constexpr] paragraph 5 says,

If the instantiated template specialization of a constexpr functiontemplate or member function of a class template would fail to satisfythe requirements for a constexpr function or constexpr constructor,that specialization is not a constexpr function or constexprconstructor. [Note: if the function is a member function itwill still beconst as described below. Implementations areencouraged to issue a warning if a function is rendered not constexprby a non-dependent construct. —end note]

A non-dependent error in a function template renders it ill-formedwith no diagnostic required (13.8 [temp.res] paragraph 8).A similar approach is being taken in the proposed resolution ofissue 1125 with respect to constexprfunctions. It would be more consistent to treat constexpr functiontemplates in the same way, along the lines of

If no specialization of the template would beconstexpr,the program is ill-formed, no diagnostic required.

Proposed resolution (November, 2010) [SUPERSEDED]:

Change 9.2.6 [dcl.constexpr] paragraph 6 as follows:

If the instantiated template specialization of a constexpr functiontemplate or member function of a class template would fail to satisfythe requirements for aconstexpr function orconstexpr constructor, that specialization is not aconstexpr function orconstexpr constructor.[Note: if the function is a member function it will still beconst as described below.Implementations areencouraged to issue a warning if a function is rendered notconstexpr by a non-dependent construct.endnote]If no specialization of the template would yield aconstexpr function orconstexpr constructor, theprogram is ill-formed; no diagnostic required.



[8]ページ先頭

©2009-2026 Movatter.jp