2017-05-25 131 views
0

结构这似乎微不足道,但在VS2015u3与初始化列表与vs2015u3

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 

不起作用

namespace Timer { 

     struct T 
     { 
      int milliseconds = 0; 
      int cmd_id = 0; 
     }; 

     T init(const HWND hwnd) { 
      T t = { 0, 0 } ; 
      return t; 
     } 
    } 

呼叫者

auto timer = Timer::init(); 

错误,我会认为这是标准随着C + + 11以上。有没有我需要设置的选项?

+0

这不仅仅是自C++ 14以来的一项功能吗? – Rakete1111

回答

1

你是对的,你只错过了VS2015 没有的部分完全支持C++标准!

如果你看看list的功能,你会发现VS2015不支持“NSDMIs for aggregates”,这是你想要的功能。

尽管Visual Studio 2017应该支持这个功能,因为它们增加了C++标准的一致性。

+0

升级时间... – Ronnie