[WIP] Use <optional> if available.
AbandonedPublic

Authored by tcberner on Dec 15 2018, 4:47 PM.

Details

Reviewers
mlaurent
dvratil
Group Reviewers
FreeBSD
Summary

FreeBSD-current recently [1] updated clang&co which means experimental/optional is no longer available,
and errors out as optional should be used.

  • check if <optional> is present using __has_include
  • simply define stdx = std

This also requires a change to Akonadi to remove the auto_ptr variant
of setPayload:

/usr/local/include/KF5/AkonadiCore/item.h:589:48: error: no template named 'auto_ptr' in namespace 'std'
    template <typename T> void setPayload(std::auto_ptr<T> p);
                                          ~~~~~^
/usr/local/include/KF5/AkonadiCore/item.h:1053:12: error: variable has incomplete type 'void'
void Item::setPayload(std::auto_ptr<T> p)
           ^
/usr/local/include/KF5/AkonadiCore/item.h:1053:28: error: no member named 'auto_ptr' in namespace 'std'
void Item::setPayload(std::auto_ptr<T> p)
                      ~~~~~^
/usr/local/include/KF5/AkonadiCore/item.h:1053:37: error: 'T' does not refer to a value
void Item::setPayload(std::auto_ptr<T> p)
                                    ^
/usr/local/include/KF5/AkonadiCore/item.h:1052:20: note: declared here
template <typename T>
                   ^
/usr/local/include/KF5/AkonadiCore/item.h:1053:40: error: use of undeclared identifier 'p'
void Item::setPayload(std::auto_ptr<T> p)
                                       ^
/usr/local/include/KF5/AkonadiCore/item.h:1053:42: error: expected ';' at end of declaration
void Item::setPayload(std::auto_ptr<T> p)
                                         ^
/usr/local/include/KF5/AkonadiCore/item.h:1054:1: error: expected unqualified-id
{
^
7 errors generated.

[1] https://svnweb.freebsd.org/base?view=revision&revision=341825

Diff Detail

Repository
R206 KMail
Branch
Applications/18.12
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 6053
Build 6071: arc lint + arc unit
tcberner created this revision.Dec 15 2018, 4:47 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptDec 15 2018, 4:47 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
tcberner requested review of this revision.Dec 15 2018, 4:47 PM
dvratil added a comment.EditedDec 16 2018, 10:44 AM

I've recently run into the same problem on Akonadi on Windows, ended up allowing C++17 on Windows only and shipping a C++14-compatible implementation of C++17 optional in 3rdparty for everyone else.

Maybe we could just get rid of the optional in this agent until we can switch to C++17 proper. I hate not having it, but it's just one or two occurrences here and probably not worth the magic to satisfy all compilers.

agents/unifiedmailboxagent/CMakeLists.txt
3

If even FreeBSD supports C++17 out of the box these days, I wonder if we can switch to 17 everywhere, or if we still need to support some ancient distros...in any case, for now, please stick to C++14.

Setting it to C++17 also triggers the auto_ptr error in Akonadi, since auto_ptr has been removed in C++17, but is present in 14. Current Akonadi master does have a fix for that , however (and couple others).

I've recently run into the same problem on Akonadi on Windows, ended up allowing C++17 on Windows only and shipping a C++14-compatible implementation of C++17 optional in 3rdparty for everyone else.

Maybe we could just get rid of the `optional` in this agent until we can switch to C++17 proper. I hate not having it, but it's just one or two occurrences here and probably not worth the magic to satisfy all compilers.

How about also using that 3rdparty optional here?

rakuco added a subscriber: rakuco.Dec 30 2018, 4:36 PM

Maybe we could just get rid of the optional in this agent until we can switch to C++17 proper. I hate not having it, but it's just one or two occurrences here and probably not worth the magic to satisfy all compilers.

Right, so would you be OK with reverting commits 39cbfe725870a94c74a9d344f81212f04aa56d30 and b44642b4ec9773abc299dcc0ca8d02797fa6b9a8?

@rakuco Yes, should be OK. I don't have access to my KDE ssh key right now so feel free to revert them and push it (to Applications/18.12 branch, then merge the branch to master), otherwise, I'll push it sometime next week.

@tcberner this can now be closed in favor of D17917.

tcberner abandoned this revision.Jan 5 2019, 12:01 AM

Thanks :)