3
以下程序是否形成不良?2默认拷贝构造函数:有可能吗?
struct Foo
{
Foo(Foo&) = default;
Foo(const Foo&) = default;
};
int main()
{
}
它成功地compiles with clang++ 3.8.0 and g++ 6.3.0(编译标志-std=c++11 -Wall -Wextra -Werror -pedantic-errors
)。
嗯..这些不是*默认*复制构造函数。这些是* default ** ed ***拷贝构造函数。除此之外,它们与以常规方式定义的复制构造函数没有区别(使用'{}')。有两个复制构造函数在参数上具有不同的const限定是没有什么不寻常的。 – AnT
@AnT我很抱歉我的英文不好。当然,默认** ed **。 – Constructor
'Foo(Foo&)'是(也)一个有效的拷贝构造函数。 – Jarod42