Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem with std::map in function find()

problem with std::map in function find()

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphics
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    baldha rakesh
    wrote on last edited by
    #1

    hi, i used template class and in this class i used map eith function pointer and string with value and key respective. with this map i find my function address that i saved previosly and call my function but in this code i have problem with find().. find return iterator which is map.end() so loop is break ... in that casse only two function pointer is working but after that it gives end of map.. so pls help to find out this problem.. also i attached my code pls go throught it . // map of operation methods typedef bool (CLbxMorphCompareImpl::*OperationMethod)(const MorphUtil::CParsedMorph *, const MorphUtil::CParsedMorph *, const std::vector &, long); typedef std::map OperationMap; OperationMap m_mapOperations; template < typename TBaseClass> CLbxMorphCompareImpl< TBaseClass>::CLbxMorphCompareImpl() { unicode::ustring ustr1 = unicode::ustring::create_from_asciiz("agree"); m_mapOperations[ustr1] = &CLbxMorphCompareImpl::OperationAgree; unicode::ustring ustr2 = unicode::ustring::create_from_asciiz("not-agree"); m_mapOperations[ustr2] = &CLbxMorphCompareImpl::OperationNotAgree; unicode::ustring ustr3 = unicode::ustring::create_from_asciiz("strict-agree"); m_mapOperations[ustr3] = &CLbxMorphCompareImpl::OperationStrictAgree; unicode::ustring ustr4 = unicode::ustring::create_from_asciiz("strict-not-agree"); m_mapOperations[ustr4] = &CLbxMorphCompareImpl::OperationStrictNotAgree; } template long CLbxMorphCompareImpl::CompareEx(uint16_t * bstrLeftReference, uint16_t * bstrRightReference, uint16_t * bstrOperation) { bool bRet = false; //TYPENAME must required in template.. typename DataTypeStockImpl::CLbxMorphCompareImpl::OperationMap::const_iterator itMethod = m_mapOperations.find(strEachOperation); } thanx a lot. rakesh baldha Thanks & Regards rakesh

    V T 2 Replies Last reply
    0
    • B baldha rakesh

      hi, i used template class and in this class i used map eith function pointer and string with value and key respective. with this map i find my function address that i saved previosly and call my function but in this code i have problem with find().. find return iterator which is map.end() so loop is break ... in that casse only two function pointer is working but after that it gives end of map.. so pls help to find out this problem.. also i attached my code pls go throught it . // map of operation methods typedef bool (CLbxMorphCompareImpl::*OperationMethod)(const MorphUtil::CParsedMorph *, const MorphUtil::CParsedMorph *, const std::vector &, long); typedef std::map OperationMap; OperationMap m_mapOperations; template < typename TBaseClass> CLbxMorphCompareImpl< TBaseClass>::CLbxMorphCompareImpl() { unicode::ustring ustr1 = unicode::ustring::create_from_asciiz("agree"); m_mapOperations[ustr1] = &CLbxMorphCompareImpl::OperationAgree; unicode::ustring ustr2 = unicode::ustring::create_from_asciiz("not-agree"); m_mapOperations[ustr2] = &CLbxMorphCompareImpl::OperationNotAgree; unicode::ustring ustr3 = unicode::ustring::create_from_asciiz("strict-agree"); m_mapOperations[ustr3] = &CLbxMorphCompareImpl::OperationStrictAgree; unicode::ustring ustr4 = unicode::ustring::create_from_asciiz("strict-not-agree"); m_mapOperations[ustr4] = &CLbxMorphCompareImpl::OperationStrictNotAgree; } template long CLbxMorphCompareImpl::CompareEx(uint16_t * bstrLeftReference, uint16_t * bstrRightReference, uint16_t * bstrOperation) { bool bRet = false; //TYPENAME must required in template.. typename DataTypeStockImpl::CLbxMorphCompareImpl::OperationMap::const_iterator itMethod = m_mapOperations.find(strEachOperation); } thanx a lot. rakesh baldha Thanks & Regards rakesh

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      post work and no work example typename must required? Kuphryn

      1 Reply Last reply
      0
      • B baldha rakesh

        hi, i used template class and in this class i used map eith function pointer and string with value and key respective. with this map i find my function address that i saved previosly and call my function but in this code i have problem with find().. find return iterator which is map.end() so loop is break ... in that casse only two function pointer is working but after that it gives end of map.. so pls help to find out this problem.. also i attached my code pls go throught it . // map of operation methods typedef bool (CLbxMorphCompareImpl::*OperationMethod)(const MorphUtil::CParsedMorph *, const MorphUtil::CParsedMorph *, const std::vector &, long); typedef std::map OperationMap; OperationMap m_mapOperations; template < typename TBaseClass> CLbxMorphCompareImpl< TBaseClass>::CLbxMorphCompareImpl() { unicode::ustring ustr1 = unicode::ustring::create_from_asciiz("agree"); m_mapOperations[ustr1] = &CLbxMorphCompareImpl::OperationAgree; unicode::ustring ustr2 = unicode::ustring::create_from_asciiz("not-agree"); m_mapOperations[ustr2] = &CLbxMorphCompareImpl::OperationNotAgree; unicode::ustring ustr3 = unicode::ustring::create_from_asciiz("strict-agree"); m_mapOperations[ustr3] = &CLbxMorphCompareImpl::OperationStrictAgree; unicode::ustring ustr4 = unicode::ustring::create_from_asciiz("strict-not-agree"); m_mapOperations[ustr4] = &CLbxMorphCompareImpl::OperationStrictNotAgree; } template long CLbxMorphCompareImpl::CompareEx(uint16_t * bstrLeftReference, uint16_t * bstrRightReference, uint16_t * bstrOperation) { bool bRet = false; //TYPENAME must required in template.. typename DataTypeStockImpl::CLbxMorphCompareImpl::OperationMap::const_iterator itMethod = m_mapOperations.find(strEachOperation); } thanx a lot. rakesh baldha Thanks & Regards rakesh

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        BKhandelwal wrote:

        with this map i find my function address that i saved previosly and call my function but in this code i have problem with find()..

        have look at simple example of MAP::find here :- How to Find All Values of Key from MultiMap?[^]

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups