
Hi Martin, Could you make the list and parent pointer private to SPDoc? And then add the const method SPDoc::find...() that returns NULL if nothing was found, and a SPDoc::linkChild(SPDoc *child) { child_documents.push_back(child); child->parent_document = this; }
(hope you can come up with better names for the methods)
Thanks, Johan
On 22-1-2014 4:21, Martin Owens wrote:
Thanks for the push Krzysztof,
I got ptr_list working I think the way you wanted, have a look at r12969 and see if it's the way you imagined.
Best Regards, Martin Owens
On Wed, 2014-01-22 at 01:20 +0100, Krzysztof KosiĆski wrote:
2014/1/21 Johan Engelen <jbc.engelen@...2592...>:
How large do we expect this list to be? I advise list<T> for now (moving onto unique_ptr when we make the switch to C++11), just for the sake of simplicity and not unnecessarily relying on external deps. I think there is a much higher chance of a dev knowing the semantics of list<unique_ptr<T>> than boost::ptr_list<T>.
Boost include-only libraries are already a dependency, even for 2Geom.
The overhead of learning boost::ptr_list when you already know how to use std::list is minimal compared to the overhead of writing boilerplate destructor code on every object that contains an std::list of pointers.
std::unique_ptr is only available in C++11 so we cannot use it yet, and std::auto_ptr cannot be put into containers.
Here are some examples.
std::ptr_list<Object> list, list2 list.push_back(new Object(1, 2, 3)); list.push_back(new DerivedObject()); list.push_back(new Object(3, 2, 1)); list.erase(list.begin()); // calls desctructor std::auto_ptr<Object> x = list.release(list.begin()); // if you want to remove an object without destroying it
Regards, Krzysztof
CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.cl... _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel