Switching to C++ 20?

I’m curious to know how many people here have started using C++ 20, and when is the “right time” to make the switch. Would I be creating headaches for myself if I decided to switch now? Are there any JUCE-specific factors that I need to take into account?

Asking because I’m working on a problem that would be trivial to solve with the new Ranges library, but is quite difficult otherwise.

You may run into problems on Linux and Mac Os because older systems won’t have new enough C++ runtimes. While much of the C++ standard library is header-only, there are also parts that need to be compiled and be available as binaries on the end user’s system.

On Windows this doesn’t appear to be a problem because the C++ runtime can be statically linked into the app/plugin binary or a dynamic runtime specific to a software can be installed/distributed. It might be possible to arrange things to work like that on Linux and Mac Os too, but it could end up complicated, it doesn’t seem to be a standard or recommended thing to do on those systems. You could of course set up the minimum system requirements for the users as needed.

You also need to disable char8_t (/Zc:char8_t- for MSVC, -fno-char8_t for GCC and Clang) -it’s incompatible with Juce right now. I’ve not run into any other issues, but I’m on Windows and I’m only using Concepts.

This table will show you whether the desired features are available on your compiler to make a decision about switching:

https://en.cppreference.com/w/cpp/compiler_support/20

For me MSVC and Apple Clang are relevant and there is too much unsupported stuff on Apple’s side to make the switch.

1 Like

Thanks for this info–looks like the Ranges library isn’t there on MSVC anyway. I hope they update soon, because I’m really looking forward to trying out some of the new features.

The table is outdated there, most of Ranges is available now (VS 16.8, cl 19.28). It’s also mostly done in GCC 10.1, but apparently there’s nothing in Clang yet.

I cannot wait to use modules, but must wait at least until its properly supported in all major compilers. However, I’m using C++20 (Lastest) in Windows and Android

1 Like

I don’t see any reason to ever not use the latest C++ standard. If there are things that aren’t implemented by Clang yet, just don’t use them, or provide your own implementation. No reason to deny yourself from using the things that are implemented.

3 Likes

I started using it and its just wonderful as the others