none
Visual Studio Editor marks error but compiles without problems when using initializer_list.

    Question

  • Hi everybody
    I am currently experimenting with C++11 and have observed a strange behaviour of the Visual Studio 2015 code editor when using an initializer_list:

    class List {
    public:
    List(const std::initializer_list<int> &list);
    };

    List list = { 5, 5, 5 };
    The editor underlines the opening bracket on the last line saying: "Error: The definition of "std::initializer_list" does not contain the expected constructor."

    The funny thing is, the code compiles nonetheless using the Microsoft as well as the GCC compiler. What am I doing wrong?

    Best regards
    Samuel
    Wednesday, March 30, 2016 5:06 PM

Answers

All replies

  • >The funny thing is, the code compiles nonetheless using the Microsoft as well as the GCC compiler. What am I doing wrong?

    It's not uncommon for the intellisense compiler to disagree with the
    actual compiler.

    Have you tried this with VS2015 update 2 to see if you still have the
    issue?

    Dave

    Wednesday, March 30, 2016 9:36 PM
  • Its funny, at the very time I was posting this inquiry, there was no update VS2015 2 yet :-p
    Wednesday, March 30, 2016 11:20 PM
  • Hi Amadeus-Zurich,

    >>Its funny, at the very time I was posting this inquiry, there was no update VS2015 2 yet.

    Does it work well now if you installed the VS2015 update 2 as Dave's suggestion?

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 31, 2016 6:41 AM
    Moderator