In one of my code std::map::find() is crashing the programm.

actually I am using map<ConstructPointer, QStringList*>;

My ConstructPointer contains and constructed by two data members of integer type (Enums), and it also have operator==() overload.

I've my own LessFunctor for Compare.

Code:typedef std::map<ConstructPointer, QStringList*, ConstructPointer::FakeLessFunctor> ConstructMap; ConstructMap constructList;In my code I am executing constructList.find() in the following wayCode:class ConstructPointer{ private: Construct c; ConstructType t; public: Construct construct(){return c;} ConstructType constructType(){return t;} public: ConstructPointer(Construct cns, ConstructType cnsT):c(cns), t(cnsT){} bool operator==(const ConstructPointer& cnsPt) const{ return (cnsPt.c == c && cnsPt.t == t); } /* friend bool operator==(const ConstructPointer& lCnsPt, const ConstructPointer& rCnsPt){ return (lCnsPt.c == rCnsPt.c && lCnsPt.t == rCnsPt.t); } */ public: struct LessFunction{ bool operator()(const ConstructPointer& lhsCnsPt, const ConstructPointer& rhsCnsPt) const{ return lhsCnsPt.t < rhsCnsPt.t; } }; struct FakeLessFunctor{ bool operator()(const ConstructPointer&, const ConstructPointer&) const{return true;} }; };

My program is crashing on the line where I am executing find().Code:ConstructPointer cnsPt(cns, cnsTp);//Constructing a new Object ConstructMap::const_iterator it = constructList.find(cnsPt);

____________________

MY INVESTIGATION

````````````````````

To investigate I looked at the STL source. where I found std::map executes find() method of Tree and from that stl_tree.h I found

So I sawCode:template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: find(const _Key& __k) const { const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); return (__j == end() || _M_impl._M_key_compare(__k, _S_key(__j._M_node))) ? end() : __j; }Code:_Rb_tree_impl<_Compare> _M_impl;and this is the _Rb_tree class template declarationCode:template<typename _Key_compare, bool _Is_pod_comparator = __is_pod(_Key_compare)> struct _Rb_tree_impl : public _Node_allocator { _Key_compare _M_key_compare;

which meansCode:template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc = allocator<_Val> > class _Rb_tree{will invoke the lessFunction's operator()() which returns bool type if lhs < rhs. ButCode:_M_key_compare(__k,_S_key(__j._M_node))how will understand by LessFunctor::operator()() wheather its equal or not