Migrating away from Boost #7
Replies: 0 comments 3 replies
-
|
I made a PR implementing some of the proposed changes. It serves as an example - of course, not everything there is set in stone. It's also work in progress, so currently it doesn't compile. The most notable change is in |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
@cantordust Thank you for all this work and starting this discussion (already more than a month ago!), sorry for not getting back to it earlier. I had a look at the related PR today and will take a look at your proposed solution and the links you shared tomorrow. I think we can indeed find a better solution than what is currently there. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
In general, reducing the number of dependencies is good for both maintainability and usability. Both
corticalsimandcorticalsim3ddepend onBoost, which is known to cause issues when upgrading between versions. Since all of the functionality provided by Boost is now available in the standard library, it should be possible to remove Boost as a dependency.I have made some trivial changes to reduce this dependency (such as using casting and filesystem functions from
std), but there is one main 'stronghold' that remains: theDLListclass, where it is used for custom allocation of new entries in a doubly linked list. Technically, there is also theCompactListclass, but the use case there is identical, so I will focus onDLList.Status quo
I have made an initial attempt to refactor the
DLListclass to remove the Boost dependency. It is much more compact and does not rely on complex pointer casts (see lns. 289-287, particularly the comment acknowledging that this is a hack). The refactored version has not been tested, but that can be done separately.However, the real problem is not with the
DLListclass but how it is used. Inserting a new element is done by one of thecreatemethods (lns. 165-194), which returns a pointer to the newly inserted element. The handling of the previous and next elements is handled manually by using thepreviousElementandnextElementattributes inDLBaseItem. For that reason, classes that need to useDLListmust derive fromDLBaseItem.By replacing the Boost version of the memory pool with an STL variant, the handling of element linkage is not handled manually any more. This makes it impossible to remove an element by using the pointer to the element. We need a new strategy.
Proposed solution
The solution that I propose is to use the memory resources that have been made part of the C++17 standard. Specifically, I propose that we use the following:
std::pmr::list) in combination with the above resources.To be discussed
The main point of this discussion is to work through the changes that need to be implemented. The main point to be discussed is moving some methods from one class to another, which would be mandated by the new DLList class. For instance,
Microtubule::wall()would need to be moved to theSystemclass and take aDLList<Microtubule>iterator as an argument).Justification
There are many advantages to using the proposed approach:
std::listiterators are not invalidated when adding or removing items.DLBaseItem) to useDLList.Beta Was this translation helpful? Give feedback.
All reactions