Skip to content

Commit

Permalink
Add PODVector::assign(value)
Browse files Browse the repository at this point in the history
```
vector.assign(vector.size(), 42);
```
is a bit verbose for a standard operation, even if it mirrors
https://en.cppreference.com/w/cpp/container/vector/assign

Add another overload similar to `setVal(ue)` used in other
AMReX containers.
  • Loading branch information
ax3l committed Apr 1, 2024
1 parent 728eec4 commit 0490a78
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Src/Base/AMReX_PODVector.H
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,15 @@ namespace amrex
(Allocator const&)(*this));
}

/** Set the same value to every element of the vector
*
* @param a_value the value to assign
*/
void assign (const & T a_value)
{
assign(m_size, a_value);
}

[[nodiscard]] allocator_type get_allocator () const noexcept { return *this; }

void push_back (const T& a_value)
Expand Down

0 comments on commit 0490a78

Please sign in to comment.