CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Issue in c

  1. #1
    Join Date
    May 2015
    Posts
    500

    Issue in c

    Hello,

    I have a structure,
    Code:
    typedef map<string, PolicyRuleInfo> listOfPolicyRuleInfo;
    
    struct IPAddressPolicyRulesInfo{
        CIPAddress sIpAddress;
        listOfPolicyRuleInfo policyRules;
        IPAddressPolicyRulesInfo(){};
        IPAddressPolicyRulesInfo(CIPAddress ipaddr, string policyRuleName, PolicyRuleInfo policyRule): sIpAddress(ipaddr){policyRules[policyRuleName]=policyRule;};
    
        void addPolicycyRule(string policyRuleName, PolicyRuleInfo policyRule) { policyRules[policyRuleName]=policyRule; }
    };
    
    And somewhere in the code
    
                                                    IPAddressPolicyRulesInfo cIpAddressPolicyRulesInfo = iTerApn->second;
    
                                                    listOfPolicyRuleInfo itPolicyRule = cIpAddressPolicyRulesInfo.policyRules.find(sDedicatedBearerId);
    
                                                    if (itPolicyRule != cIpAddressPolicyRulesInfo.policyRules.end())
    and getting compilation error:
    error: no match for 'operator!=' in 'itPolicyRule != cIpAddressPolicyRulesInfo.IPAddressPolicyRulesInfo:olicyRules.std::map<_Key, _Tp, _Compare, _Alloc>::end [with _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Tp = PolicyRuleInfo, _Compare = std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<std:air<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, PolicyRuleInfo> >]()'

    Could the c++ experts give some quick advice and help me with this please ?

    thanks a lot,
    ~p

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Issue in c

    map<>::find() returns a map<>::iterator http://en.cppreference.com/w/cpp/container/map/find

    so something like:
    Code:
    listOfPolicyRuleInfo::iterator it = cIpAddressPolicyRulesInfo.policyRules.find(sDedicatedBearerId);
    // Check it against policyRules.end()
    gg

  3. #3
    Join Date
    May 2015
    Posts
    500

    Re: Issue in c

    Thanks gg for the reply..
    But i,e what i am also doing:
    if (itPolicyRule != cIpAddressPolicyRulesInfo.policyRules.end())

    and getting the above mentioned compile error

  4. #4
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Issue in c

    Code:
    listOfPolicyRuleInfo itPolicyRule = ...
    itPolicyRule is the wrong type.

    gg

  5. #5
    Join Date
    May 2015
    Posts
    500

    Re: Issue in c

    yes, i was in hurry and didnt notice this silly mistake..Thanks a lot

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured