Migrate to C++17 #5470
Replies: 5 comments
-
Hi @oleg-derevenetz , there are few reasons why didn't move to C++17 in the past:
I think the first point is not relevant anymore and our code is in a (relatively) pretty good shape with C++11. The second point requires an analysis how many and which platforms we are going to drop to support. Overall, there are no big barriers to move C++17 now. |
Beta Was this translation helpful? Give feedback.
-
Hi @ihhub Yeah, it looks like we will need to drop the VS2015 support. On the other hand, we use VS2019 in our CI anyway, and, according to this table, VS2017 supports the C++17 just fine and it can build for WinXP, so we can replace VS2015 project files by VS2017 project files and still have target audience on WinXP (but they will need to build the project themselves, just like now). Regarding other platforms, GCC has C++17 from GCC 7 onwards (was released in 2017) and Clang has the full support of core C++17 features from Clang 6 onwards (was released in 2018), so it shouldn't be a problem on Linux or relatively modern versions of macOS. It looks like Switch and PSV toolsets use the modern GCC as well. |
Beta Was this translation helpful? Give feedback.
-
If this only brings with it benefits then why not. My only question is whether this means I have to avoid writing code in a specific way or change the old code in a certain way whenever I'm working on it. |
Beta Was this translation helpful? Give feedback.
-
No, it doesn't mean this :) A number of new features will be available, but there is no need to necessarily use them. |
Beta Was this translation helpful? Give feedback.
-
We moved to C++17 so I am locking this discussion. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @ihhub @idshibanov @zenseii what do you think about migrating to C++17? Sometimes features from it would be useful. For example, when I write code like this:
fheroes2/src/fheroes2/ai/normal/ai_normal_kingdom.cpp
Lines 97 to 107 in d94c531
I'm always afraid to mix something up -
firstRecruit
withsecondRecruit
or.first
with.second
. With C++17 I would write like this:Much less error-prone, no chance to mix something up at all, but the same efficiency due to the local templated lambda which will be inlined.
Beta Was this translation helpful? Give feedback.
All reactions