JUCE_HAS_CONSTEXPR in VS2015


#1

I’m sure there was a good reason why this was done, but I can’t seem to find it on the forums:

 #if _MSC_VER >= 1910
  #define JUCE_HAS_CONSTEXPR 1
 #endif

I believe this macro can be moved to the >= 1900 section. Testing it locally in VS2015 works out just fine in the Demo and my apps.

I’m trying to make use of that new Grid stuff!


#2

IIRC it was because VS2015 supported some of the ways you can use constexpr, but not all of them. I think perhaps constexpr functions worked, but not variables (?)


#3

VS2015 does support constexpr variables.

https://msdn.microsoft.com/en-us/library/hh567368.aspx


#4

OK, but I’m sure I remember us all getting annoyed about something it didn’t support… @fabian @t0m can you remember?


#5

I couldn’t possibly know what types of hassle you guys were running into… If it helps any, VS2015’s constexpr support is C++11 with some C++14:

VS2017 appears to go further by supporting C++14 (mostly or fully?) with some C++17:


#6

As far as I recall, VS2015 had some bugs with constexpr when it came out. So most use cases would work as advertised, but not all. I believe they have ironed them out now, so the C++11 use cases (constexpr variables and single-statement constexpr functions) should all work. After all, VS2015 successfully compiles Microsoft’s own STL which is full of constexpr stuff.

And obviously VS2017 goes beyond and adds C++14 stuff like allowing constexpr functions to have branches and loops, and declare and mutate local variables.


#7

So I would second @jrlanglois and recommend this change.


#8

OK. I just pushed this. It will be available on develop shortly.


#9

Thanks folks!