array::operator=

Assignment operators.

Synopsis

array&
operator=(
    array const& other); (1)

array&
operator=(
    array&& other); (2)

array&
operator=(
    std::initializer_list< value_ref > init); (3)

Description

Replaces the contents of the array.

  • (1) the contents are replaced with an element-wise copy of other.

  • (2) takes ownership of other's element storage if *storage() == *other.storage(); otherwise equivalent to (1).

  • (3) the contents are replaced with a copy of the values in init.

After (2), the moved-from array behaves as if newly constructed with its current storage pointer.

Complexity

  • (1) linear in size() + other.size().

  • (2) constant if *storage() == *other.storage(); otherwise linear in size() + other.size().

Exception Safety

(2) provides strong guarantee if *storage() != *other.storage() and no-throw guarantee otherwise. Other overloads provide strong guarantee. Calls to memory_resource::allocate may throw.

Parameters

Name Description

other

The array to copy.

init

The initializer list to copy.