Reputation: 3271
This seems trivial but doesn't work
namespace Timer {
struct T
{
int milliseconds = 0;
int cmd_id = 0;
};
T init(const HWND hwnd) {
T t = { 0, 0 } ;
return t;
}
}
caller
auto timer = Timer::init();
Errors in VS2015u3 with
h:\lfwin32\lfwin32.h(21): error C2440: 'initializing': cannot convert from 'initializer list' to 'LFWin32::Timer::T'
h:\lfwin32\lfwin32.h(21): note: No constructor could take the source type, or constructor overload resolution was ambiguous
I would have thought this was standard with C++11 onwards. Is there an option I need to set?
Upvotes: 0
Views: 101
Reputation: 48958
You are correct, you're only missing the part that VS2015 doesn't support C++ standards completely!
If you look at the list of features, you'll see that VS2015 doesn't support "NSDMIs for aggregates", which is the feature you want.
Visual Studio 2017 should support this feature though, as they increased their C++ Standard conformance.
Upvotes: 1