Title
Constexpr member functions of class templates
Status
c++11
Section
9.2.6 [dcl.constexpr]
Submitter
Jens Maurer

Created on 2008-06-27.00:00:00 last changed 96 months ago

Messages

Date: 2010-08-23.00:00:00

[Voted into WP at August, 2010 meeting.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

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

If the instantiated template specialization of a constexpr function template or member function of a class template would fail to satisfy the requirements for a constexpr function or constexpr constructor, the constexpr specifier is ignored that specialization is not a constexpr function or constexpr constructor. [Note: if the function is a member function it will still be const as described below. Implementations are encouraged to issue a warning if a function was rendered not constexpr by a non-dependent construct. —end note]
Date: 2009-07-15.00:00:00

Notes from the July, 2009 meeting:

The consensus of the CWG was that an “ignored” constexpr specifier in this case simply means that the specialization is not constexpr, not that it is not const. The CWG also decided not to address the question of non-dependent expressions that render a function template specialization non-constexpr, leaving it to quality of implementation whether a (warning) diagnostic is issued in such cases.

Date: 2008-09-15.00:00:00

Notes from the September, 2008 meeting:

This question is more involved than it might appear. For example, a constexpr member function is implicitly const; if the constexpr specifier is ignored, does that make the member function non-const? Also, should this provision apply only to dependent expressions in the function? Should it be an error if no constexpr function can be instantiated from the template, along the lines of the permission given in 13.8 [temp.res] paragraph 8 for an implementation to diagnose a template definition from which no valid specialization can be instantiated?

Date: 2008-06-27.00:00:00

9.2.6 [dcl.constexpr] paragraph 5 applies only to “the instantiated template specialization of a constexpr function template;” it should presumably apply to non-template member functions of a class template, as well.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: wp -> fdis
2010-11-29 00:00:00adminsetstatus: dr -> wp
2010-08-23 00:00:00adminsetmessages: + msg2911
2010-08-23 00:00:00adminsetstatus: review -> dr
2010-02-16 00:00:00adminsetmessages: + msg2532
2010-02-16 00:00:00adminsetstatus: drafting -> review
2009-08-03 00:00:00adminsetmessages: + msg2194
2009-08-03 00:00:00adminsetstatus: open -> drafting
2008-10-05 00:00:00adminsetmessages: + msg1795
2008-06-27 00:00:00admincreate