problem with std::map in function find()
-
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
-
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
-
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
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