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

2025-10-11


3072. Incorrect examples for lambda SFINAE

Section: 13.10.3.1  [temp.deduct.general]     Status: open     Submitter: Brian Bi     Date: 2025-09-13

(From submission #761.)

After issue 2672, the third and fourth comments in Example 7 in 13.10.3.1 [temp.deduct.general] paragraph 9 incorrectly treat the lambda-introducer and trailing return type of a lambda as if they were part of the lambda body.

Suggested resolution:

Change in 13.10.3.1 [temp.deduct.general] paragraph 9 as follows:

[ Example: ...
  template <class T>
    auto h(T) -> decltype([x = T::invalid]() { });
  void h(...);
  h(0);        // error: invalid expression not part of the immediate context OK, calls h(...)

  template <class T>
    auto i(T) -> decltype([]() -> typename T::invalid { });
  void i(...);
  i(0);        // error: invalid expression not part of the immediate context OK, calls i(...)

  template <class T>
    auto j(T t) -> decltype([](auto x) -> decltype(x.invalid) { } (t)); // #1
  void j(...);      // #2

  j(0);             // deduction fails on #1, OK, calls #2 j(...)
-- end example ]