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

            Bug ID: 153294
           Summary: Use copy_if, find_if or remove_if to simplify loops
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: LibreOffice
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: hoss...@libreoffice.org

Since C++11, STL provides means to process containers easier than before via
the available functions inside <algorithm>.

In tdf#153109, I have suggested using std::all_of, std::any_of and
std::none_of.

Here, I suggest to simplify loops via std::copy_if, find_if or remove_if:

std::copy_if
https://cplusplus.com/reference/algorithm/copy_if/

std::find_if
https://cplusplus.com/reference/algorithm/find_if/

std::remove_if
https://cplusplus.com/reference/algorithm/remove_if/

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:

Different methods to copy in C++ STL | std::copy(), copy_n(), copy_if(),
copy_backward()
https://www.geeksforgeeks.org/different-methods-copy-c-stl-stdcopy-copy_n-copy_if-copy_backward/

For an example of such changes inside LibreOffice code, see this commit:

Simplify Sequence iterations in lingucomponent..lotuswordpro
760a377f7148e623e9e16d24e66f54a401ecb946

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