Skip to content

Conversation

@ax3l
Copy link
Member

@ax3l ax3l commented Apr 1, 2024

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
  • 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

@ax3l ax3l requested review from WeiqunZhang and atmyers April 1, 2024 20:33
*
* @param a_value the value to assign
*/
void assign (const & T a_value)
Copy link
Member Author

@ax3l ax3l Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also avoid an overload and call this setVal(value) in symmetry with MultiFab, what do you think?

Suggested change
void assign (const & T a_value)
void setVal (const T& a_value)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In MultiFabs, we further overload the assignment operator for amrex::Real and/or int, for convenience.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think assign is fine. It will still be asymmetric unless we add assign to MultiFab, which most versions would not make sense.

```
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.
@ax3l ax3l force-pushed the podv-assign-all branch from 0490a78 to 79cf650 Compare April 1, 2024 22:35
@WeiqunZhang WeiqunZhang merged commit f2536be into AMReX-Codes:development Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants