更新时间:2023-02-27 10:46:41
这是一个Intellisense错误。 clang和gcc都接受此代码, webcompiler,在线Visual c ++编译器也接受此代码。
This is an Intellisense bug. Both clang and gcc accept this code, also webcompiler an online Visual c++ compiler accepts this code.
C ++ 14标准草案 12.1
[class.ctor] 表示默认的默认构造函数如果满足以下条件,则删除该类:
The draft C++14 standard section 12.1
[class.ctor] says a defaulted default constructor for a class is deleted if:
- X是类联合的类,其变体成员具有非-琐碎的默认构造函数,
- 没有大括号或相等初始化器的任何非静态数据成员都是引用类型,
- 任何非-没有大括号等于初始化器的const限定类型(或其数组)的变体非静态数据成员没有
用户提供的默认构造函数,- X是一个工会,其所有变体成员都是const限定类型(或其数组)。
- X是非工会类,任何匿名工会成员的所有成员都是const-限定类型(或其数组)
- 任何可能构造的子对象,除了具有大括号或等于初始化器的非静态数据成员外,其类类型为M(或其数组
),并且M没有默认构造函数或重载应用于M的默认构造函数的
分辨率(13.3)导致
的歧义性或导致从
默认的默认构造函数或$ b中删除或无法访问的函数- 任何可能构造的子对象都具有带有析构函数的类型,该析构函数已从默认的默认
构造函数中删除或无法访问。
- X is a union-like class that has a variant member with a non-trivial default constructor,
- any non-static data member with no brace-or-equal-initializer is of reference type,
- any non-variant non-static data member of const-qualified type (or array thereof) with no brace-orequal- initializer does not have a user-provided default constructor,
- X is a union and all of its variant members are of const-qualified type (or array thereof),
- X is a non-union class and all members of any anonymous union member are of const-qualified type (or array thereof),
- any potentially constructed subobject, except for a non-static data member with a brace-or-equalinitializer, has class type M (or array thereof) and either M has no default constructor or overload resolution (13.3) as applied to M’s default constructor results in an ambiguity or in a function that is deleted or inaccessible from the defaulted default constructor, or
- any potentially constructed subobject has a type with a destructor that is deleted or inaccessible from the defaulted default constructor.
在此均不适用。
更新
在OP提交的错误报告中,响应为:
In the bug report filed by the OP the response was:
感谢您报告此问题。该修补程序应该在Visual Studio 2015的下一次更新中可用。
Thank you for reporting this issue. Fix should be available in the next update to Visual Studio 2015.