POD类型是否可以具有带有明确声明的默认移动分配运算符?

时间:2019-04-25 08:51:58

标签: c++ visual-c++ g++

考虑以下代码:

// in main.cpp
#include <type_traits>

struct A {
    A& operator=(const A&) = default;
    A& operator=(A&&) = default;
};

int main() {
    static_assert(std::is_pod<A>::value);
    return 0;
}

您会看到struct A有一个默认的移动分配运算符。

msvc(VS2017)中,我的cl /std:c++17 main.cpp出现了静态断言失败。

g ++(MinGW-W64,8.1.0)中,使用g++ -std=c++17 main.cpp,一切正常。

但是,如果我注释掉A& operator=(A&&) = default;,在两个编译器中都可以。

那么,POD类型是否可以具有一个默认移动赋值运算符,并带有明确声明的内容?

0 个答案:

没有答案