Skip to content

Discussion: upgrading to C++17 #16684

@dongcarl

Description

@dongcarl

UPDATE: Release plan summary from April 2nd, 2020 meeting:

C++11 Compat C++17 Compat Gitian/Guix Release
v0.20 ✔️ if easy C++11
v0.21 ✔️ ✔️ C++17
v0.22 ✔️ C++17

Meeting logs can be found here: http://www.erisian.com.au/meetbot/bitcoin-core-dev/2020/bitcoin-core-dev.2020-04-02-19.01.log.html


There were some discussion around upgrading to C++17. It seems to be able to give us library and language features that will simplify future code. For example, for library features, our current optional.h is just a wrapper around boost::optional, and can be replaced with std::optional. Other library features that might be useful include (non-exhaustively): std::variant, the file system library, and std::shared_mutex. @elichai has kindly provided a table summarizing features useful for Bitcoin Core here: #16684 (comment).

I want to apologize for misspeaking about C++17 requiring GCC8, that is untrue, and I believe all of the features we would want will be covered by GCC7, and some by GCC6.

For some background on the cons: #13356 (comment)


Default GCC versions major distros (as of Aug 22nd):

Operating System release version GCC version Notes
✔️ Debian Buster 8.3
✔️ Ubuntu 18.04 LTS 7.4
✔️ Fedora 30 9.1.1
✔️ RHEL 8 8.2
CentOS 7 4.8.5 CentOS 8 (GCC 8.2) is being released as we speak

In-depth code examples of

C++17 features: https://github.com/AnthonyCalandra/modern-cpp-features/blob/master/CPP17.md
C++14 features: https://github.com/AnthonyCalandra/modern-cpp-features/blob/master/CPP14.md


Here are some compatibility tables from https://en.cppreference.com/w/cpp/compiler_support#cpp17

Library features:
Screen Shot 2019-08-22 at 19 39 24

Language features:
Screen Shot 2019-08-22 at 19 38 32

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions