Skip to content

Commit f2536be

Browse files
authored
Add PODVector::assign(value) (#3866)
## Summary ``` 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. ## Additional background AMReX-Codes/pyamrex#222 (comment) ## Checklist The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [x] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent 728eec4 commit f2536be

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Src/Base/AMReX_PODVector.H

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,15 @@ namespace amrex
512512
(Allocator const&)(*this));
513513
}
514514

515+
/** Set the same value to every element of the vector
516+
*
517+
* @param a_value the value to assign
518+
*/
519+
void assign (const T& a_value)
520+
{
521+
assign(m_size, a_value);
522+
}
523+
515524
[[nodiscard]] allocator_type get_allocator () const noexcept { return *this; }
516525

517526
void push_back (const T& a_value)

0 commit comments

Comments
 (0)