stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
752 stars 188 forks source link

Move up to C++17 #1300

Open SteveBronder opened 5 years ago

SteveBronder commented 5 years ago

Description

Jw, what are the blockers that stop us from moving to C++17?

There's a couple features that I think would be nice. From here

From that same wiki page it looks like we would have to bump up the supported compiler versions?

GCC since version 7 has complete support for C++17. GCC C++ standards status Clang 5 and later implement all the features of C++17. clang C++ standards status

Current Version:

v2.20.0

SteveBronder commented 3 years ago

For if constexpr in particular we could use BOOST_IF_CONSTEXPR but personally I'd really like to avoid having macros everywhere (you can see in the example branch we would have to use this everywhere).

But there's a lot of stuff that we can't macro out. There's a list of C++17 niceties here here of new C++17 features (full list here). In particular things like structured bindings, Template argument deduction for class templates, folding expressions, etc. Having these features would clean up a lot of current stuff that's gross we need to do that is simple with 17

SteveBronder commented 3 years ago

@bgoodri does rstan still need to test windows on older gcc versions or is the minimum version of gcc now 8+?

bgoodri commented 3 years ago

We will probably require R >= 4.x in April, in which case RTools based on gcc 4.9 would no longer be supported and the C++17 flag is an option. I don't think 100% of C++17 was in g++-8 but it is close.

On Tue, Jan 12, 2021 at 4:48 PM Steve Bronder notifications@github.com wrote:

@bgoodri https://github.com/bgoodri does rstan still need to test windows on older gcc versions or is the minimum version of gcc now 8+?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/math/issues/1300#issuecomment-759053369, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ2XKV5XTGSSHGAOXSVRZ3SZS7TXANCNFSM4IJJSR7A .

SteveBronder commented 3 years ago

Looking at the support sheet it seems like gcc8 is the version that finalizes 17

https://gcc.gnu.org/projects/cxx-status.html#cxx17

bgoodri commented 3 years ago

For some operationalization of final. The page it links to

https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017

lists the known exceptions, but it was pretty close in g++-8.

On Tue, Jan 12, 2021 at 11:24 PM Steve Bronder notifications@github.com wrote:

Looking at the support sheet it seems like gcc8 is the version that finalizes 17

https://gcc.gnu.org/projects/cxx-status.html#cxx17

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/math/issues/1300#issuecomment-759196417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ2XKVJ5KYDJYOMUSM4E7DSZUN75ANCNFSM4IJJSR7A .

SteveBronder commented 3 years ago

ah icic, looking over that it mostly seems like the stuff that didn't get into 8 is related to working with chars, strings, file system, the parallism TS, and the memory_resource header. I think thats fine?