Bug 92459 - o3tl: replace depreciated unary_function and binary_function
Summary: o3tl: replace depreciated unary_function and binary_function
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: medium normal
Assignee: Daniel L Robertson
URL:
Whiteboard: target:5.1.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2015-06-30 15:26 UTC by Daniel L Robertson
Modified: 2016-10-25 19:20 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel L Robertson 2015-06-30 15:26:01 UTC
include/o3tl/compat_functional.hxx includes 5 classes that are derived from unary_function/binary_function, which is depreciated since C++11. The classes are as follows.

- project1st
- project2nd
- select1st
- select2nd
- unary_compose - https://bugs.documentfoundation.org/show_bug.cgi?id=91112 will fix this

Search for all instances of project1st, project2nd, select1st, and select2nd and replace them using a lambda expression as recommended in the following.

- http://en.cppreference.com/w/cpp/utility/functional/unary_function
- http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3145.html

Unless I'm mistaken, once tdf#91112 and the above have been resolved include/o3tl/compat_functional.hxx may be removed.

I'm new to contributing to LibreOffice. If you disagree with me or have any suggestions please let me know. I will not take offense. All advice and suggestions are welcome.
Comment 1 Daniel L Robertson 2015-06-30 15:29:33 UTC
I have begun to work on this, and have assigned this to myself.
Comment 2 Commit Notification 2015-07-15 23:52:08 UTC
danlrobertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5a61d7f049a81d6e747d9d097f364ae45f58697b

tdf#92459 replace unary_function in forms

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2015-07-31 19:45:01 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1a5e176e626d70d19abe4ad6e3b5c8d54a7badd7

tdf#92459 Replace select1st for lambda expressions

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2015-08-01 15:45:04 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5916d5866c109b17471a9c8604635612a0aa69ae

tdf#92459 replace deprecated o3tl features

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2015-08-08 12:29:03 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=717b23ef2765678a5598d652956edd77d2d62fc5

tdf#92459 replace deprecated o3tl features

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2015-08-08 12:32:23 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4ce10ff6ce725212efa91a017a61e1bd781008c1

tdf#92459 remove compat_functional from extensions

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Thorsten Behrens (allotropia) 2015-08-08 12:54:25 UTC
(In reply to Commit Notification from comment #6)
> Daniel Robertson committed a patch related to this issue.
>
Looking at some of the changes, and the amount of select1st/select2nd still there - would perhaps retaining a generic version of those, and their usage instead of individual lambda functions, be somtimes easier to the eye of a casual code reader? select1st is a pretty descriptive name (if not nested deep inside a bind expression, of course).
Comment 8 Daniel L Robertson 2015-08-08 14:39:39 UTC
> would perhaps retaining a generic version of those, and their usage instead of individual lambda functions, be somtimes easier to the eye of a casual code reader?

Honestly, I still consider myself to be a noobie with libreoffice, so I trust you. If you think it is better to keep select1st/2nd, I'm 100% okay with that. However, the main reasons why I started working on this was not entirely to improve readability, however in many cases it does. The main reason why I started, was to try to remove unary_function/binary_function from libreoffice (select1st/2nd are derived from unary_function), as they are deprecated since c++11. I also wanted to work on a very simple bug to get used to contributing to libreoffice. In addition, if select1st/2nd are removed, after #91112 is resolved o3tl/compat_functional can be completely removed.

> the amount of select1st/select2nd still there.

If I'm not mistaken, if the following get merged, select1st/2nd should be completely removed.

https://gerrit.libreoffice.org/#/c/17586/
https://gerrit.libreoffice.org/#/c/17588/
https://gerrit.libreoffice.org/#/c/17589/

Again, constructive criticism is welcome :-)
Comment 9 Thorsten Behrens (allotropia) 2015-08-08 17:15:57 UTC
(In reply to Daniel L Robertson from comment #8)
> > would perhaps retaining a generic version of those, and their usage instead of individual lambda functions, be somtimes easier to the eye of a casual code reader?
> 
> Honestly, I still consider myself to be a noobie with libreoffice, so I
> trust you. If you think it is better to keep select1st/2nd, I'm 100% okay
> with that.
>
I think it's more self-documenting to have code like

    std::algo( in, out, select1st< type::subtype >() );

rather than

    std::algo( in, out, []( const ::std::pair<bla,fasl>& in ) { return in.first} );

A reader of the code will have much more to parse, and mentally typecheck, to figure out what the 2nd version is doing.

That said - from the patches you did, quite a number of them IMO *did* become simpler with an overall lambda, than they were before with some nested function templates.

> However, the main reasons why I started working on this was not
> entirely to improve readability, however in many cases it does. The main
> reason why I started, was to try to remove unary_function/binary_function
> from libreoffice (select1st/2nd are derived from unary_function), as they
> are deprecated since c++11.
>
Sure, this is much appreciated! Though the they don't *have* to be derived from unary/binary_function.

> In addition, if select1st/2nd are removed, after #91112 is resolved
> o3tl/compat_functional can be completely removed.
>
So how about moving some trimmed-down version of select1st/2nd then to o3tl/functional.hxx? It's not about compatibility then anymore, but for sharing some 20-odd cases of the same pattern.
Comment 10 Daniel L Robertson 2015-08-10 15:11:19 UTC
> Sure, this is much appreciated! Though the they don't *have* to be derived from > unary/binary_function.

So simple, but I never thought of that. After I looked at select1st/2nd, I noticed they were only intended to be used for pair's, so I uploaded the following patch which does the same thing without being derived from unary_function and using std::pair's typedefs (first_type && second_type).

https://gerrit.libreoffice.org/#/c/17625/
Comment 11 Commit Notification 2015-08-11 13:30:11 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=647b5aecd4c3facc302df33386451dda732aab98

tdf#92459 remove compat_functional from canvas

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2015-08-11 22:22:19 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f6595f0b3389ffeefa10035d915a884b02d26c0e

tdf#92459 remove o3tl/compat_functional.hxx

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Commit Notification 2015-08-11 22:24:37 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ae6afadbc0c6ffcdbfd0db6bb3b0166295d5effd

tdf#92459 o3tl: remove unary_function

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2015-08-11 22:30:11 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=87130a4e18347d055331ff53da3b1a79548ff24a

tdf#92459 Cleanup unclear lambdas

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 15 Commit Notification 2015-08-13 05:35:34 UTC
Daniel Robertson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3babca3e849e1cb42225ca1c26e8f6156ad153e6

tdf#92459 basebmp: replace project2nd

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 16 Daniel L Robertson 2015-08-14 14:21:46 UTC
With the last commit, this is resolved
Comment 17 Robinson Tryon (qubit) 2015-12-16 00:11:30 UTC Comment hidden (obsolete)