Reputation: 7895
I am watching a video series on youtube by Jason Tuner and on this particular video found here: Aggregate Initializations he starts off using clang++ c++03 and then changes compiler to clang++ c++11 then when he incorporates the base class hierarchy he changes it to using c++17 or c++1z using a recent build of clang++.
I have just recently downloaded and installed MSVS2017RC and I'm running Windows 7 64bit SP1 on an Intel Quad Core Extreme.
However when I try to follow his video while having this in my IDE
struct B {
double q;
};
struct S : B {
int i;
float f;
};
int main() {
S s{ {}, 1, 2.3f };
return s.f;
}
I am getting this compiler error:
1>------ Build started: Project: Test1z, Configuration: Debug Win32 ------
1>stdafx.cpp
1>Test1z.cpp
1>c:\users\skilz80\documents\visual studio 2017\projects\test1z\test1z\test1z.cpp(15): error C2440: 'initializing': cannot convert from 'initializer list' to 'S'
1>c:\users\skilz80\documents\visual studio 2017\projects\test1z\test1z\test1z.cpp(15): note: No constructor could take the source type, or constructor overload resolution was ambiguous
1>c:\users\skilz80\documents\visual studio 2017\projects\test1z\test1z\test1z.cpp(16): warning C4244: 'return': conversion from 'float' to 'int', possible loss of data
1>Done building project "Test1z.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Does Visual Studio 2017 have the support of these features that are found in c++17? If so are there special compiler options that need to be set in the project properties? Or is this currently exclusive to clang or gcc? What is the main reason for MS's compiler error C2440
if this is supposed to be a c++17 compiler?
Upvotes: 4
Views: 872
Reputation: 473222
Visual Studio 2017 does not support all, or most, of C++17 at the present time. Among the things it does not support is aggregate initialization of base classes.
Upvotes: 6