Re: [boost] property tree find no match for 'operator=='
 
            
            
            
            
                30 Sep
                
                    2011
                
            
            
                30 Sep
                
                '11
                
            
            
            
        
    
                9:17 p.m.
            
        ----- "Bernd Prager" <bernd@prager.ws> a écrit :
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?
For your problem, the two iterators are not of the same type. Don't know the exact reason, but I know that ptree uses multi_index. Might be related. Anyway : - you have a get_optional() method. - you can try replacing end() with not_found() Regards, Ivan
        5145
        
      
          Age (days ago)
        
      
        5145
        
    
          Last active (days ago)
        
        
        
        0 comments
    
    
        
        1 participants
    
    
    
    
    
    
    
    
    participants (1)
- 
                 Ivan Le Lann Ivan Le Lann