Skip to content

AstAttributeMechanism::operator=

Assignment operator.

Synopsis

Declared in <src/midend/astProcessing/AstAttributeMechanism.h>

AstAttributeMechanism&
operator=(AstAttributeMechanism const& other);

Description

Assigning one attribute container to another will cause the destination container's attributes to be erased and deleted, and the source container's attributes to be copied. The assignment operator is exception safe: it will either successfully copy and assign all attributes or not assign any attributes. However, if an attribute uses anything other than the AstAttribute::CONTAINER_OWNERSHIP ownership policy then it is up to the attribute type's designer to handle deletion of attributes that were copied before the exception occurred.

New semantics: The original implementation had a copy constructor but no assignment operator. Assignment of one attribute container to another caused both containers to share the attribute values allocated on the heap, making it nearly impossible to figure out when they could be safely deleted and therefore leading to memory leaks.

Return Value

Reference to the current object

Parameters

Name

Description

other

The object to copy assign from

Created with MrDocs