[Property_tree] using find to find a key

Hi: I am declaring a property_tree, pulating this with an ini file. I then need to find out whether a section (key) is present, so I'm doing: boost::property_tree::ptree::assoc_iterator it =IniTree.find(key); if (it !=boost::property_tree::ptree::not_found) using visual c++ 2010 I get an error c2678, telling me that no operand is able to use these two values. Can someone please tell me what I'm doing wrong, as I can normally do this for std::vectors etc! Cheers Sean.

On 29.01.2012, at 12:19, Sean Farrow wrote:
Hi: I am declaring a property_tree, pulating this with an ini file. I then need to find out whether a section (key) is present, so I’m doing: boost::property_tree::ptree::assoc_iterator it =IniTree.find(key); if (it !=boost::property_tree::ptree::not_found) using visual c++ 2010 I get an error c2678, telling me that no operand is able to use these two values. Can someone please tell me what I’m doing wrong, as I can normally do this for std::vectors etc!
not_found is a function. This should work:
if (it !=boost::property_tree::ptree::not_found())
Sebastian

Wirked a charm, thanks. Sean. From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Sebastian Redl Sent: 29 January 2012 15:57 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Property_tree] using find to find a key Importance: High On 29.01.2012, at 12:19, Sean Farrow wrote: Hi: I am declaring a property_tree, pulating this with an ini file. I then need to find out whether a section (key) is present, so I'm doing: boost::property_tree::ptree::assoc_iterator it =IniTree.find(key); if (it !=boost::property_tree::ptree::not_found) using visual c++ 2010 I get an error c2678, telling me that no operand is able to use these two values. Can someone please tell me what I'm doing wrong, as I can normally do this for std::vectors etc! not_found is a function. This should work: if (it !=boost::property_tree::ptree::not_found()) Sebastian
participants (2)
-
Sean Farrow
-
Sebastian Redl