PODs, non-PODs, rvalue and lvalues

前端 未结 3 2093
说谎
说谎 2020-12-25 13:21

Could anyone explain the details in terms of rvalues, lvalues, PODs, and non-PODs the reason why the first expression marked below is not ok while the secon

3条回答
  •  离开以前
    2020-12-25 13:55

    From Does C++ do value initialization of a POD typedef?, which quotes the Standard:

    The expression T(), where T is a simple-type-specifier (7.1.5.2) for a non-array complete object type or the (possibly cv-qualified) void type, creates an rvalue of the specified type, which is value-initialized

    Therefore int() is an rvalue and can't be assigned to, as you saw in your first case.

    A() would not be a simlle-type-specifyer and thus A() yields an lvalue

提交回复
热议问题