Skip to main content
fix spellings and grammar
Source Link
cigien
  • 61.2k
  • 11
  • 86
  • 124

P1061R10 mentions "empty" twice, but doesn't answer your question directly and the latest C++26 draft doesn't include the wording for P1061 yet, but, I dare to say Yes.

In P1061, the authors showsshow many examples of how letting structured bindingbindings introduce packs simplifies generic code where std::apply must be used Todaytoday, sometimes in multiple layers. Even the implementation of std::apply itself could be simplified to

template <class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) {
    auto&& [...elems] = t;
    return std::invoke(std::forward<F>(f),
                       forward_like<Tuple, decltype(elems)>(elems)...);
}

according to the proposal. If empty packs will not be allowed, this implementation of std::apply would not work, and neither would many other situations in generic code.

Therefore, it's without question that the authors mentmeant for empty packs to be allowed.

(Also, the experimental implementation of P1061 in clangClang accepts them: Demo)

P1061R10 mentions "empty" twice, but doesn't answer your question directly and the latest C++26 draft doesn't include the wording for P1061 yet, but, I dare to say Yes.

In P1061, the authors shows many examples of how letting structured binding introduce packs simplifies generic code where std::apply must be used Today, sometimes in multiple layers. Even the implementation of std::apply itself could be simplified to

template <class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) {
    auto&& [...elems] = t;
    return std::invoke(std::forward<F>(f),
                       forward_like<Tuple, decltype(elems)>(elems)...);
}

according to the proposal. If empty packs will not be allowed, this implementation of std::apply would not work, and neither would many other situations in generic code.

Therefore, it's without question that the authors ment for empty packs to be allowed.

(Also, the experimental implementation of P1061 in clang accepts them: Demo)

P1061R10 mentions "empty" twice, but doesn't answer your question directly and the latest C++26 draft doesn't include the wording for P1061 yet, but, I dare to say Yes.

In P1061, the authors show many examples of how letting structured bindings introduce packs simplifies generic code where std::apply must be used today, sometimes in multiple layers. Even the implementation of std::apply itself could be simplified to

template <class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) {
    auto&& [...elems] = t;
    return std::invoke(std::forward<F>(f),
                       forward_like<Tuple, decltype(elems)>(elems)...);
}

according to the proposal. If empty packs will not be allowed, this implementation of std::apply would not work, and neither would many other situations in generic code.

Therefore, it's without question that the authors meant for empty packs to be allowed.

(Also, the experimental implementation of P1061 in Clang accepts them: Demo)

edited body
Source Link
Ted Lyngmo
  • 124.1k
  • 7
  • 93
  • 155

P1061R10 mentions "empty" twice, but doesn't answer your question directly and the latest C++26 draft doesn't include the wording for P1061 yet, but, I dare to say Yes.

In P1061, the authors shows many examples of how letting structured binding introduce packs simplifies generic code where std::apply must be used Today, sometimes in multiple layers. Even the implementation of std::apply itself could be simplified to

template <class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) {
    auto&& [...elems] = t;
    return std::invoke(std::forward<F>(f),
                       forward_like<Tuple, decltype(elems)>(elems)...);
}

according to the proposal. If empty packs will not be allowed, this implementation of std::apply would not work, and neither would many other situations in generic code.

I therefore thinkTherefore, it's without question that the authors ment for empty packs to be allowed.

Also(Also, the experimental implementation of P1061 in clang accepts it.them: Demo)

P1061R10 mentions "empty" twice, but doesn't answer your question directly and the latest C++26 draft doesn't include the wording for P1061 yet, but, I dare to say Yes.

In P1061, the authors shows many examples how letting structured binding introduce packs simplifies generic code where std::apply must be used Today, sometimes in multiple layers. Even the implementation of std::apply itself could be simplified to

template <class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) {
    auto&& [...elems] = t;
    return std::invoke(std::forward<F>(f),
                       forward_like<Tuple, decltype(elems)>(elems)...);
}

according to the proposal. If empty packs will not be allowed, this implementation of std::apply would not work, and neither would many other situations in generic code.

I therefore think it's without question that the authors ment for empty packs to be allowed.

Also, the experimental implementation of P1061 in clang accepts it. Demo

P1061R10 mentions "empty" twice, but doesn't answer your question directly and the latest C++26 draft doesn't include the wording for P1061 yet, but, I dare to say Yes.

In P1061, the authors shows many examples of how letting structured binding introduce packs simplifies generic code where std::apply must be used Today, sometimes in multiple layers. Even the implementation of std::apply itself could be simplified to

template <class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) {
    auto&& [...elems] = t;
    return std::invoke(std::forward<F>(f),
                       forward_like<Tuple, decltype(elems)>(elems)...);
}

according to the proposal. If empty packs will not be allowed, this implementation of std::apply would not work, and neither would many other situations in generic code.

Therefore, it's without question that the authors ment for empty packs to be allowed.

(Also, the experimental implementation of P1061 in clang accepts them: Demo)

Source Link
Ted Lyngmo
  • 124.1k
  • 7
  • 93
  • 155

P1061R10 mentions "empty" twice, but doesn't answer your question directly and the latest C++26 draft doesn't include the wording for P1061 yet, but, I dare to say Yes.

In P1061, the authors shows many examples how letting structured binding introduce packs simplifies generic code where std::apply must be used Today, sometimes in multiple layers. Even the implementation of std::apply itself could be simplified to

template <class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) {
    auto&& [...elems] = t;
    return std::invoke(std::forward<F>(f),
                       forward_like<Tuple, decltype(elems)>(elems)...);
}

according to the proposal. If empty packs will not be allowed, this implementation of std::apply would not work, and neither would many other situations in generic code.

I therefore think it's without question that the authors ment for empty packs to be allowed.

Also, the experimental implementation of P1061 in clang accepts it. Demo