Std::map屏蔽排序功能
#include <map>
template<class T>
struct DisableCompare : public std::binary_function<T, T, bool>
{
bool operator()(T lhs, T rhs) const
{
if (lhs == rhs)
return false;
return true;
}
};
定义map的时候:
typedef std::map<std::string, std::string, DisableCompare<std::string>> InfoMap; //屏蔽掉map本身按key排序的功能