https://bugs.documentfoundation.org/show_bug.cgi?id=153109

            Bug ID: 153109
           Summary: Use all_of, any_of or none_of from STD instead of
                    looping to check a condition over a container
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: LibreOffice
          Assignee: [email protected]
          Reporter: [email protected]

Since C++11, STL provides means to process containers easier than before. Some
of the available functions inside <algorithm> are describe below:

std::all_of
  Test the condition on all of the elements
  https://cplusplus.com/reference/algorithm/all_of/
std::any_of
  Test if any element satisfies the condition
  https://cplusplus.com/reference/algorithm/any_of/
std::none_of
  Test if no elements satisfies the condition
  https://cplusplus.com/reference/algorithm/none_of/

In the above links, you can find description for each of the above functions.
Beyond that, you can find good tutorials for these functions. For example:

The big STL Algorithms tutorial: all_of, any_of, none_of
https://www.sandordargo.com/blog/2019/02/20/stl-algorithm-tutorial-part-1-any-all-none

For examples of such changes inside LibreOffice code, see this commits:

writerfilter: use std::any_of()
e542b622aeb70230365971cab4838dbe0b6e0a93%5E%21

desktop: simplify code by std::none_of
b4848def4684ad277af23a10d73b4b5c9cb201fb

xmloff: simplify code by using std::all_of/std::any_of/std::none_of
c675a2d669c191f3b18ae006c78ef83efba14c30

You have to make sure that you keep the code behavior unchanged when using the
above STD functions.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to