C++ const-correctness in 2020

It has been a while since I last wrote something for the blog. This should only take about a minute.

I don’t know if writing C++ used to be fun. But it sure isn’t any more.

A constexpr specifier used in an object declaration or non-static member function (until C++14) implies const.

In other words, a constexpr non-static member function is not implicitly const from C++14 onwards.

class Foo {
  constexpr Bar const&
  do_something(std::shared_ptr<const Bar> const& bar, float const baz) const;

  // ...
};

Welcome to the year 2020 ladies and gentlemen. Can’t wait to write a ton of C.


PS, this is all const “tongue-in-cheek”. Take with a const grain of salt.

PPS, know how to make it const worse? Please let me know.