This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112c. See for the official list.


2274. Generic lambda capture vs constexpr if

Section: 8.5.2  [stmt.if]     Status: NAD     Submitter: Richard Smith     Date: 2016-06-20


  template<typename Iter> void f(Iter a, Iter b) {
    const int v = 10;
    auto do_something = [&] (auto thing) {
      if constexpr (is_random_access_iterator<Iter> && is_integral<decltype(thing)>)
        *(a + 1) = v;

Determining whether v is captured requires instantiating the "if constexpr", but that results in a hard error for a statement that will eventually be discarded.

Rationale (February, 2018):

These questions were resolved by the adoption of paper P0588R1 at the November, 2017 meeting.