Use std::initializer_list in Visual C++ Compiler November 2012 CTP

前端 未结 2 721
-上瘾入骨i
-上瘾入骨i 2021-01-12 15:53

I want to use std::initializer_lists in Visual Studio 2012 like a guy in this example does. My operating system is Windows 8 x64.

Therefore I lately ins

相关标签:
2条回答
  • 2021-01-12 16:32

    (I work for Microsoft and with Dinkumware to maintain VC's Standard Library implementation.)

    [danijar]

    I am not sure if it could be caused by the fact that I am (sadly) using the German edition of Visual Studio and the compiler update is in English.

    Unfortunately, the English-only CTP does not support German VS.

    The "compiler driver" cl.exe is what invokes the compiler front-end c1xx.dll, the compiler back-end c2.dll, and the linker link.exe. It is very unusual for the compiler driver to crash. I speculate that it's attempting to display one of the error messages that were added by the CTP, but since the CTP didn't update the German resources, the compiler driver can't load the error message and proceeds to crash.

    Note that this is different from an Internal Compiler Error in the front-end or back-end, or a normal compiler error that happens to be incorrectly emitted. (Many ICEs and bogus errors have been fixed after the CTP was released.)

    But even after doing so, there is neither a std::initializer_list nor a <initializer_list> header available.

    The CTP installed <initializer_list> in a special location. (It was actually written by the compiler team.)

    On the command line, the incantations to use the CTP and put <initializer_list> on the include path are (assuming default locations):

    "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
    set PATH=C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP\bin;%PATH%
    set INCLUDE=C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP\include;%INCLUDE%
    

    Trying to compile the line auto a = { 0 }; which is criticized by IntelliSense

    This was documented - Intellisense was not updated by the CTP, therefore it will not recognize any of the new features.

    [rubenvb]

    The C++ Standard Library was not updated with the compiler, leaving you without decent <tuple> and <intializer_list> (this includes the omission of the braced init list constructors for all standard containers)

    You may be interested to learn that we've updated the standard library to fully support scoped enums and initializer lists. This includes all initializer_list overloads mandated by the current Working Paper (N3485), plus installing <initializer_list> in the usual location along with all other standard headers. (It is also Dinkumware's official copy, although the differences between it and the compiler team's "fake" version were mostly cosmetic.) This stuff will be available in the next public release, whenever and whatever that is. Our next task is to update the standard library with explicit conversion operators and variadic templates, replacing our brittle simulations.

    0 讨论(0)
  • 2021-01-12 16:47

    As you have noticed, the November CTP is very limited in usability for at least two reasons:

    1. The compiler has numerous crash-causing bugs, such as the one you discovered.

    2. The C++ Standard Library was not updated with the compiler, leaving you without decent <tuple> and <intializer_list> (this includes the omission of the braced init list constructors for all standard containers)

    Also: the linked example is very ugly code. If you want to use this feature, use a compiler like GCC or Clang that supports this syntax. They are both available for Windows. Hacking around a half-implemented language feature by writing extra code is just stupid.

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