constexpr not compiling in VC2013

前端 未结 4 1224
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 06:14

This constexpr code does not compiled in Visual Studio 2013 version 12.0.21005.1 REL

Is there a newer Visual Studio compiler that works with constexpr?



        
相关标签:
4条回答
  • 2020-11-30 07:08

    As is mentioned by the others, November 2013 Customer Technology Preview(CTP) will give you access to constexpr*

    Note that just downloading the you'll need to change your "Platform Toolset" to "Visual C++ Compiler Nov 2013 CTP (CTP_Nov2013)" to use the new compiler. You can do that by opening your project's "Property Pages" And going to: "Configuration Properties" > "General" and then changing the "Platform Toolset".

    *There is a bit of conflicting information on what portion of constexpr you actually have access to, but it's definitely not all of the standards definition of constexpr. Microsoft says here that the November 2013 CTP adds:

    constexpr support (except for constructors)

    Microsoft say here that it contains:

    constexpr (except for member functions)

    I can't even test if it has support for member functions, cause it definitely doesn't have support for any type of constexpr construction. For example this code gives this error with the November 2013 CTP:

    error C2127: illegal initialization of 'constexpr' entity with a non-constant expression

    One additional note: At time of writing the Visual Studio 2015 Preview still does not support constexpr construction. Keeping my fingers crossed on the final release.

    0 讨论(0)
  • 2020-11-30 07:09

    Microsoft publishes a C++11 compatibility table, under which constexpr is clearly marked as not being available in Visual Studio 2013.

    The November 2013 CTP has it, though.

    Source: Google visual studio constexpr

    0 讨论(0)
  • 2020-11-30 07:10

    You need to install VS2013 Update 5. (I was on Update 3 and it was not working) The thing about "Nov 2013 CTP" was inapplicable, as of this writing. You can do so by going here: https://my.visualstudio.com

    and going to download, or : https://my.visualstudio.com/Downloads?q=visual%20studio%202013

    0 讨论(0)
  • 2020-11-30 07:13

    constexpr is not supported in Visual Studio 2013 RTM, see the compatibility table. This is not only true for the RTM version, but also for the Visual Studio Updates.

    If you want to stick to Visual Studio 2013, you could download the Visual C++ Compiler November 2013 CTP which comes with some new features, see MSDN blog. Unfortunately Microsoft has no merger with the latest Visual Studio Update features and the CTP features and clearly states that they don't plan to do so.

    If we want it all, we need to wait for Visual Studio 2015, see the MSDN blog about VS 2015 Preview.

    0 讨论(0)
提交回复
热议问题