[clug] Watercooler - was Open Source Developers in CBR

Luke Mewburn lukem-clug at mewburn.net
Sun Sep 6 23:13:07 UTC 2020

On 20-09-07 08:09, Hugh Fisher via linux wrote:
  | On Sun, Sep 6, 2020 at 5:27 PM Brenton Ross via linux
  | <linux at lists.samba.org> wrote:
  | [ munch ]
  | >
  | > Hence my first sub-project is to build a C++ wrapper for the Redland C
  | > library. I started with the source from the existing project, but ended
  | > just keeping one of its core design features and rewriting most of it
  | > using C++ features that are more recent than what the original author
  | > used.
  | >
  | What version of C++ are you using (11, 14, 17) and why? Every time
  | I've looked at the newer editions of C++ I've been terrified by all the
  | features.

Re which C++ version to consider.

I think the biggest benefits started from C++11, but the incremental
features in C++14 and C++17 may be useful too.

IMHO, some of the simpler quality of life improvements in C++11 are:
- auto (when not abused; still want people to understand your code
- range-based for loops, especially when used with auto:
	for (const auto & i: someContainer) { ... }
- default functions, for constructors, destructors, copy/move operators, etc.
- delegating constructors (no more private init() methods :)

A minor improvement in C++17 I like is structured bindings:
	for (const auto & [key, val]: someMap) { ... }

As to compiler support: g++ 7 has full C++17 support.
g++ 7.3 is available in RHEL/CentOS 7 (and 6) via SCL devtoolset-7, which
requires a bit of trickery to use but after a while but you get used to
	scl enable devtoolset-7 'make'
RHEL/CentOS 8 has g++ 8.3
Looks like Debian 10 has g++ 8 in "g++-8",
Ubuntu 18.04 defaults to g++ 7.4, Ubuntu 20.04 defaults to g++ 9.2.

Some useful resources:
- C++ Core Guidelines [by Stroustrup & Sutter]
- What are the differences between C++11 and C++14 C++17?
- C++20/17/14/11 [Modern C++ features]


More information about the linux mailing list