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

ygm::container variable reassignment using std::swap #115

Open
bwpriest opened this issue Dec 22, 2022 · 0 comments
Open

ygm::container variable reassignment using std::swap #115

bwpriest opened this issue Dec 22, 2022 · 0 comments

Comments

@bwpriest
Copy link
Member

It would be valuable to reassign container objects inline using the = operator. For example, I have workflows where I iteratively build containers while discarding old versions. It would be very convenient to do so via something like:

ygm::container::map<key_type, value_type> my_map = make_map();
while(condition == true) {
  my_map = make_new_map(my_map);
}

This does not currently work, and I believe we need to add an overloaded = operator for each container with an implementation like

container_type &operator=(container_type rhs) {
  std::swap(*this, rhs);
  return *this;
}

We will probably need to do some accounting with the ygm_ptrs for the objects in this case, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant