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

Iter to stl #1751

Closed
wants to merge 2 commits into from
Closed

Conversation

christopherlam
Copy link
Contributor

More iter changes.

  • to fully be compatible with std::find_if and friends, the GncTreeIter seems to need iterator traits inherited from std::iterator. See the class definition
  • GncTreeContainer adds an append() methods which adds a new GtkTreeIter and returns its GncTreeIter.
  • GncTreeIter adds a get_gtk_tree_iter to return the GtkTreeIter to be useful when find_if returns the GncTreeIter. This creates another method to access the GtkTreeIter; one from the GncTreeIter and another from GncTreeData. The benefit is this allows:
 auto iter = std::find_if (...);
 gtk_list_store_set (store, &iter.get_gtk_tree_iter(), ...)

instead of the uglier

 auto iter = std::find_if (...);
 gtk_list_store_set (store, &(*iter).get_iter(), ...)
  • Adds an example std::find_if use in import-match-picker.cpp.

…ter()

- GncTreeContainer::append() creates a new GncTreeIter in the model

- GncTreeIter::get_gtk_tree_iter() returns the GtkTreeIter being held

- GncTreeIter also inherits from std::iterator<std::forward_iterator_tag>
  so that std::find_if can work

---

This creates two (potentially confusing) methods to retrieve the
GtkTreeIter from these classes:

1. GncTreeData::get_iter() returns &m_iter

2. GncTreeIter::get_gtk_tree_iter() also returns &m_iter

It would seem for (auto iter : container) returns a GncTreeData whose
GtkTreeIter is accessed via iter.get_iter().

However `iter = std::find_if(container.begin(), container.end(),
predicate)` returns a GncTreeIter whose GtkTreeIter is accessed via
iter.get_gtk_tree_iter().
@christopherlam
Copy link
Contributor Author

Closed because although this compiles, it segfaults when running.

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

Successfully merging this pull request may close these issues.

1 participant