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-28


2774. Value-dependence of requires-expressions

Section: 13.8.3.4  [temp.dep.constexpr]     Status: open     Submitter: Christof Meerwald     Date: 2023-07-17

Consider:

   template<typename T>
   struct A
   {
     static_assert(sizeof(T) == 3);    // #1
   };

   template<bool B>
   struct C
   {
     static_assert(B);                 // #2
   };

   template<typename T, typename U>
   int f(typename C<requires { typename T::type; }>::type, typename A<T>::type, U);

   int i = f<char>(0, 1, 2);

Is the requires-expression value-dependent after substituting the explicit template argument, thus failing at #2 instead of at #1?

Suggested resolution:

  1. Change in 13.8.3.3 [temp.dep.expr] paragraph 4 as follows:

    Expressions of the following forms are never type-dependent (because the type of the expression cannot be dependent):
      ...
      noexcept ( expression )
      requires-expression
    
  2. Insert a new paragraph before 13.8.3.4 [temp.dep.constexpr] paragraph 5:

    A requires-expression is value-dependent if it depends on a template parameter.

    An expression of the form &qualified-id where the qualified-id names a dependent member ...

CWG 2023-08-25

The first change has consensus and is progressed via issue 2785; the second change should use an approach of recursive decomposition for requires-expression, similar to other paragraphs in 13.8.3.4 [temp.dep.constexpr]. The implementation divergence is believed to be an independent bug in one implementation.