2017-05-25 127 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