https://bugs.documentfoundation.org/show_bug.cgi?id=170269
Bug ID: 170269
Summary: Use C++20 ranges all_of, any_of or none_of to simplify
loops for checking a condition over a range
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: LibreOffice
Assignee: [email protected]
Reporter: [email protected]
Since C++20, it is possible to process containers in an easier form with
std::ranges. One can rewrite loops checking a condition over a range with
std::ranges functions. It is also simpler compared to C++11 syntax.
There are multiple functions available in ranges library:
Constrained algorithms (since C++20)
https://en.cppreference.com/w/cpp/algorithm/ranges.html
These are defined in <algorithm> header:
std::ranges::all_of
Test the condition on all of the elements
std::ranges::any_of
Test if any element satisfies the condition
std::ranges::none_of
Test if no elements satisfies the condition
You can find further information below. Above functions are part of
"Non-modifying sequence operations":
https://en.cppreference.com/w/cpp/algorithm/ranges/all_any_none_of.html
The new std::ranges has a simpler syntax compared to the older std::all_of,
etc. functions used in tdf#153109, and is a replacement, in most cases.
For an example commit, see this patch:
Use C++20 std::ranges::all_of instead of a loop
https://gerrit.libreoffice.org/c/core/+/196851
Please make sure that you keep the code behavior unchanged.
--
You are receiving this mail because:
You are the assignee for the bug.