Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PODVector::assign(value) #3866

Merged
merged 1 commit into from
Apr 2, 2024

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

*
* @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.
@WeiqunZhang WeiqunZhang merged commit f2536be into AMReX-Codes:development Apr 2, 2024
68 of 69 checks passed
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