Title
constexpr member functions in brace-or-equal-initializers
Status
dup
Section
7.7 [expr.const]
Submitter
Daveed Vandevoorde

Created on 2013-02-19.00:00:00 last changed 5 months ago

Messages

Date: 2024-06-29.11:12:13

CWG 2024-06-28

CWG opined that, contrary to the assertion in the issue, the treatment of non-templated class definitions should be changed to more closely resemble templated ones. This direction is covered by issue 2335.

Date: 2013-02-19.00:00:00

The Standard should make clear that a constexpr member function cannot be used in a constant expression until its class is complete. For example:

  template<typename T> struct C {
    template<typename T2> static constexpr bool _S_chk() {
      return false;
    }
    static const bool __value = _S_chk<int>();
  };

  C<double> c;

Current implementations accept this, although they reject the corresponding non-template case:

  struct C {
    static constexpr bool _S_chk() { return false; }
    static const bool __value = _S_chk();
  };

  C c;

Presumably the template case should be handled consistently with the non-template case.

History
Date User Action Args
2024-06-29 11:12:13adminsetmessages: + msg7765
2024-06-29 11:12:13adminsetstatus: open -> dup
2022-02-18 07:47:23adminsetstatus: drafting -> open
2013-05-03 00:00:00adminsetstatus: open -> drafting
2013-02-19 00:00:00admincreate