property tree find no match for 'operator=='

All, This is likely to be a silly question. I am trying to check for the existence of a value in a property tree. Reading the docs I assumed the easiest way would be: namespace pt = boost::property_tree; static pt::ptree pt; bool has(const std::string key) { if (pt.find(key) == pt.end()) return false; // (1) return true; } The compiler complains about "error: no match for 'operator=='" in line (1) though. What am I missing? Thank you for any help, -- Bernd

On 30.09.2011, at 19:17, Bernd Prager wrote:
All,
This is likely to be a silly question. I am trying to check for the existence of a value in a property tree.
Reading the docs I assumed the easiest way would be:
namespace pt = boost::property_tree; static pt::ptree pt;
bool has(const std::string key) { if (pt.find(key) == pt.end()) return false; // (1) return true; }
The compiler complains about "error: no match for 'operator=='" in line (1) though. What am I missing?
Because of a peculiarity of PTree, the iterator returned by find() is not compatible with those returned by begin() and end(). You must compare with not_found() to get the result you want. Sebastian
participants (2)
-
Bernd Prager
-
Sebastian Redl