Skip to content

SiteSystem move-assignment operator #1

@lkeegan

Description

@lkeegan

Normally this move-assignment would take a SiteParameters &&site_parameters argument like the move constructor above it:

SiteParameters &operator=(
SiteParameters &site_parameters) // Changed on my own from no & to && (from DevDat other to &&other)

same here:
SiteSystem &
operator=(SiteSystem &site_system) // Changed on my own from no & to && (from DevDat other to &&other)

As written it does work just fine as a move-assignment operator, e.g. assuming we have SiteParameters a and b, we can assign the contents of a to b

b = std::move(a);

but it also acts like a copy-assignment operator (that steals the original object's data), so we can also do this::

b = a;

but the user would probably be surprised to find a has been altered in this code.

Instead with && the second example won't compile, since a here is an l-value/not a temporary, and there is no copy assignment operator defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions