// some class class ANode { public: /// constructor ANode() : d_id(-1){} /// constructor ANode(int id) : d_id(id){} /// destructor ~ANode(){} public: int d_id; int d_dummy_int[3]; char d_dummy_char; }; // comparison function for std::set struct ltptr { bool operator()(const ANode* ptr0, const ANode* ptr1) const { return ptr0 - ptr1; } }; // ... somewhere in the code std::set< ANode*, ltptr > ptrset;
p0 - p1 = 0x804c0e8 - 0x804c008 = -14316557560x804c0e8 > 0x804c008, but the result is minus value! This is gcc 3.3.4, Linux 32 bit case.