我有這樣的代碼:C5027「移動賦值操作符被隱式定義爲刪除」
template < typename TFunc >
class Foo
{
public:
Foo(TFunc func) : func_(func) {}
Foo(Foo<TFunc> const &) = delete;
Foo<TFunc> & operator=(Foo<TFunc> const &) = delete;
Foo(Foo<TFunc> &&) = default;
Foo<TFunc> & operator=(Foo<TFunc> &&) = default;
private:
TFunc func_;
};
int main()
{
auto func = []() {};
auto f = Foo<decltype(func)>(func);
return 0;
}
當我編譯此代碼與Visual Studio 2015年與/Wall
標誌,我得到以下警告:
C5027 'Foo<main::<lambda_e5404f82e4b38ca1d164ce09039df46c>>': move assignment operator was implicitly defined as deleted
我不明白爲什麼移動賦值運算符會被隱式定義爲刪除,而明確定義爲默認。任何想法?
保持你的VS2015安裝更新後,這個bug被修復的更新1 –
我有版本更新14.0.25431.01 3這是很重要的,是不是最新版本? – user1735003
我也得到這個警告(用'/ Wall')。 – molbdnilo