It seems a bug in boost::property_tree when I use custom allocator.
I use custom stl allocator to replace std::basic_string like this: typedef std::basic_string<char, std::char_traits<char>, MySTLAllocator<char> > MyString; I want basic_ptree can use my allocator to do parse work, so I write code like this: typedef boost::property_tree::basic_ptree<MyString, MyString> PropertyTree; PropertyTree propertyTree; boost::property_tree::read_ini(std::ifstream(configFile.c_str()), propertyTree); And I met error at ini_parser.hpp, line 109~111: Str key = property_tree::detail::trim( line.substr(1, end - 1), stream.getloc()); if (local.find(key) != local.not_found()) the Str is a typedef at the begin of this function: typedef std::basic_string<Ch> Str; So my custom string can not assign to the key, so it seems can not use custom allocator at all. There have the same problem in xml_parser.
On Wed, 29 Dec 2010 07:47:33 +0100, SONGFY <911songfeiyu@163.com> wrote:
I use custom stl allocator to replace std::basic_string like this: typedef std::basic_string<char, std::char_traits<char>, MySTLAllocator<char> > MyString; I want basic_ptree can use my allocator to do parse work, so I write code like this: typedef boost::property_tree::basic_ptree<MyString, MyString> PropertyTree; PropertyTree propertyTree; boost::property_tree::read_ini(std::ifstream(configFile.c_str()), propertyTree); And I met error at ini_parser.hpp, line 109~111: Str key = property_tree::detail::trim( line.substr(1, end - 1), stream.getloc()); if (local.find(key) != local.not_found()) the Str is a typedef at the begin of this function: typedef std::basic_string<Ch> Str; So my custom string can not assign to the key, so it seems can not use custom allocator at all. There have the same problem in xml_parser.
Can you try changing the typedef to: typedef std::basic_string<Ch, std::char_traits<Ch>, typename Ptree::key_type::allocator_type<Ch> > Str; or even to: typedef typename Ptree::key_type Str; This requires the key to be a string. But then the implementation of read_ini() makes me wonder whether this isn't required already anyway. You might also want to submit a ticket to https://svn.boost.org/trac/boost/. Boris
participants (2)
-
Boris Schaeling
-
SONGFY