Boost C++ Libraries: Ticket #5806: Property tree supporting custom allocators such as the boost pool ones https://svn.boost.org/trac10/ticket/5806 <p> I'm currently working on a c++ extension based on custom allocators and i wanted to use property_tree in my serialization section as it seems very well designed, but i'm stuck with the fact that basic_ptree doesn't allow an allocator type to be passed as argument. It would be very nice to add custom allocation to property_tree so that we can : first customize internal ptree allocations and then use customized version of STL with it. regards. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5806 Trac 1.4.3 Sebastian Redl Tue, 23 Aug 2011 11:55:39 GMT <link>https://svn.boost.org/trac10/ticket/5806#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5806#comment:1</guid> <description> <p> PTree's design (which predates my stewardship) makes custom allocators tricky. Stateless allocators can be done without too much trouble, but stateful allocators are inefficient (needs an allocation and refcounting) and complicated to implement (since you don't want to penalize the stateless case). </p> </description> <category>Ticket</category> </item> <item> <author>vivien.millet@…</author> <pubDate>Tue, 23 Aug 2011 12:36:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5806#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5806#comment:2</guid> <description> <p> I don't get it :) how can it be penalizing if the user can choose it's own allocator through template instanciation like STL does, which can be either stateless or stateful ones (eventually providing a default one if user don't provide it) ? </p> <p> I've seen in the ptree_implementation.hpp somewhere in the constructors : </p> <p> : m_Children(new typename subs::base_container). </p> <p> Correct me if i'm wrong but is this couldn't be replaced by : </p> <p> m_Children = _Alloc::rebind&lt;typename subs::base_container&gt;::other::allocate(); </p> <p> new (m_Children) typename subs::base_container; </p> <p> "_Alloc" being the template argument we add to </p> <p> basic_ptree&lt;class K,class D,class Comp,class _Alloc = std::allocator&lt;any_type_since_we_use_rebind&gt;&gt; </p> <p> regards. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 23 Aug 2011 13:00:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5806#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5806#comment:3</guid> <description> <p> I made a mistake, allocate() method in std::allocator isn't static. But we could imagine storing an allocator object in the basic_ptree still using rebind, or providing a default allocator using static methods which invoke basic malloc and free. </p> <p> regards. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sebastian Redl</dc:creator> <pubDate>Tue, 23 Aug 2011 13:40:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5806#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5806#comment:4</guid> <description> <p> In STL containers, there is a container object which owns all the values inside. An STL container does not contain children of its own type. </p> <p> A PTree node contains children of its own type. You can obtain a reference to any subnode of the tree. There is no container that owns all nodes in the tree; instead every node owns its children, and the root is implicitly the node that isn't owned by any other. There are no up pointers in the tree. </p> <p> Because all nodes have the same type and no node can access its parent (and thus neither any other ancestor), there is no authoritative place to store a stateful allocator. This means that *every* node would need a copy or at least reference to a stateful allocator. </p> <p> As I said, supporting stateless allocators wouldn't be much trouble. (Still would be some trouble - PTree has a lot of template arguments as it is.) Still, with C++11 and its new allocators around the corner, I feel this is the worst time to add allocator support possible. </p> </description> <category>Ticket</category> </item> <item> <author>vivien.millet@…</author> <pubDate>Tue, 23 Aug 2011 14:53:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5806#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5806#comment:5</guid> <description> <p> I understand more the problem now, thanks. The best would be to accept only static method allocators such as boost::fast_pool_allocator, but if it's not in your plan to modify custom allocation right now, i understand. I think i will do my own modified implementation to fit my project if i can, waiting for C++11. </p> <p> Do you know exactly what C++11 will change concerning allocators which make you prefer not modifying any code relative to them ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sebastian Redl</dc:creator> <pubDate>Wed, 21 Jan 2015 13:14:19 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/5806#comment:6 https://svn.boost.org/trac10/ticket/5806#comment:6 <ul> <li><strong>owner</strong> changed from <span class="trac-author">kaalus</span> to <span class="trac-author">Sebastian Redl</span> </li> </ul> Ticket