Meeting 18 January 2018

Spectre mitigations in MSVC

CppCast: Meltdown and Spectre with Matt Godbolt


Tweet by STL

Free books from O’Reilly

Awesome C++


A curated list of awesome C/C++ frameworks, libraries, resources, and shiny things.

C++17 Review from PVS-Studio


Exceptions vs expected: Let’s find a compromise

PostReddit thread

  • Exceptions: Writing exception safe code is hard
  • Exceptions are not easily composable: There is only one current exception, you can’t have multiple ones. This was a problem, for example, for the C++17 parallel algorithms. What if an exception is thrown in multiple of the worker threads? How to report all of them back to the caller? The implementation gave up on solving that problem and just decided to terminate the program if any exception is thrown.
  • As with most things, the disadvantages are opposites: “exceptions are too implicit!” — “ADTs are too explicit!”

You’re writing a library and have a function that may fail — how do you report the error? If you want to write a truly flexible API, you have to do both: exceptions and error return codes. Because sometimes the error is “exceptional” and sometimes it isn’t.

Swift chose to use exceptions. (Swift doesn’t use exceptions — GD)

defer allows guaranteed cleanup without the boilerplate of RAII" (defer is equivalent to finally, and what boilerplate is that? — GD)

Rust: ADT for error handling. Result<T,E>.

 1result = foo();
 2if (!result)
 3  return result.error();
 4// do something with result.value()
 6// old way
 7result = try!(foo());
 9// new built-in language feature
10result = foo()?;

Introduction to proposed std::expected - Niall Douglas - Meeting C++ 2017

How to handle errors in constructors without exceptions


If you do not have exceptions, reporting errors from a constructor is impossible without sacrificing guarantees. Where possible, simply use an alternative and non-recoverable way of error reporting.

If that’s not applicable, provide a static function as the only way to create the object. It does not return an object directly, but an optional type. Carefully craft the implementation, so that the actual private constructor will only be called, when no operation can fail. Then every object will be valid, just like it were the case when using exceptions.

A call for data on exceptions, by Simon Brand


std::optional and the m word - Simon Brand - Meeting C++ 2017

Reddit: What are the weakest points of C++ in your opinion?


  • Setting up a build environment, adding third party libraries, like pulling teeth. #
  • Unicode support #
  • Rust and D got mentioned
  • Template metaprogramming is ridiculously verbose and complicated (but Concepts will help) #
  • “The biggest strength and weakness of C++ is its legacy” #
  • Header files #
  • “Every time there is a proposal accepted in a given standard, it is getting fixes and amendments for the next ten years” #
  • “Complexity. It could be reasoned that C++ is the most complex programming language ever created.”
  • String manipulation #
  • The preprocessor #
  • Lack of a consistent stable ABI #
  • Lack of reflection #
  • Compile times
  • Irregular void

Kate Gregory - It’s Complicated - Meeting C++ 2017 Keynote


  • Know the language (all of it)
  • Know C++ idioms
  • Follow C++ Core Guidelines
  • Write simple code

C++ poetry


1void spanish_inquisition() noexcept
3    throw std::unexpected;



Kevlin Henney:

A common fallacy is to assume authors of incomprehensible code will be able to express themselves clearly in comments.

Steve C. McConnell:

The problem with quick and dirty is that the dirty remains long after the quick has been forgotten.