C++ Logo

std-proposals

Advanced search

Re: [std-proposals] for ( repeat_count )

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Mon, 23 Oct 2023 12:02:42 +0200
The current modern way for a for loop with fixed number of iterations probably would be to use iota. #include <algorithm> #include <ranges> using std::ranges::for_each; using std::ranges::views::iota; int main() { for (auto i : iota(10)) Get(); // or for_each(iota(10), [](auto i) { Get(); }); } -----Ursprüngliche Nachricht----- Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Mo 23.10.2023 11:18 Betreff:[std-proposals] for ( repeat_count ) An:std-proposals <std-proposals_at_[hidden]>; CC:Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>; What if the following: for ( usigned i = 0u; i < len; ++i ) *p++ = Get(); Could be written as simply: for ( len ) *p++ = Get(); -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-10-23 10:02:43