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

2024-04-18


1316. constexpr function requirements and class scope

Section: 9.2.6  [dcl.constexpr]     Status: NAD     Submitter: Jason Merrill     Date: 2011-0512

A constexpr function is required to have literal argument and return types. Consider an example like:

  template <class T> struct B {
    constexpr B(T) { }
  };

  struct A {
    B<A> b;
  };

Whether B(A) is constexpr depends on whether A is literal, which depends on whether B<A> is literal, which depends on whether B(A) is constexpr.

Rationale (August, 2011):

The requirements apply to definitions, not declarations.