CLK icon indicating copy to clipboard operation
CLK copied to clipboard

Potential C++20 improvements

Open TomHarte opened this issue 2 years ago • 2 comments

A bit of a laundry list, as and when they reveal themselves:

  • std::popcount(x) & 1 is optimised to direct use of the parity flag on x86 on all mainstream compilers, and looks like the sensible log2() list of eors on ARM;
  • the bit header also provides direct access to rotates, and fast byte swaps which are likely to be essential to supporting the 68020 and above, that permit unaligned big-endian reads.

Also std::filesystem could be used to avoid e.g. get_extension in the static analyser as of C++17 but on the Mac is only implemented as of macOS v10.15 so will need to wait for a version bump there.

TomHarte avatar May 10 '23 18:05 TomHarte

std::filesystem […] is only implemented as of macOS v10.15

It's implemented in the version of libc++ included with macOS 10.15 and later but is otherwise independent of the macOS version. You could continue to support older macOS versions by building a newer version of libc++ and using that libc++ when you build Clock Signal and including that libc++ in your app bundle. All that could potentially be automated in the CMake and Xcode build systems but no need to start investigating that until you decide you want to use std::filesystem.

ryandesign avatar Mar 23 '24 06:03 ryandesign

There is also a third-party std::filesystem-compatible header-only library called ghc::filesystem (no relation to ghc) that requires nothing more than C++11.

ryandesign avatar Apr 15 '24 10:04 ryandesign