afritz1/OpenTESArena

C++20

afritz1 opened this issue · 3 comments

Not high priority, just wanted to investigate whether it was worth upgrading to get std::span and some other features.

Need to make sure this works in a few compilers:

  • MSVC
  • GCC on Debian and Raspberry Pi
  • AppleClang

Probably only involves increasing the number in CMakeLists.txt:

set(CMAKE_CXX_STANDARD 17)

Changing that line to

set(CMAKE_CXX_STANDARD 20) 

seems to work with AppleClang 14 and #include <span> at least compiles.

As long we don't use language features that are supported in some of the compilers we target but not others, it shouldn't be an issue to switch to C++20 (this chart shows features, but isn't updated for AppleClang 14).

Briefly tested in Ubuntu via WSL2. It was still GCC 9 something and didn't recognize std::span even with -std=c++2a, so might wait a bit more for this.

Upgraded to C++20 in dcc8e55 but not sure yet how aggressively I'll reach for the new features. My GCC version in WSL is only 9.4.0 from 2019. In theory this change should be relatively fine because it's a standard from 3 years ago.