My requirement here is to merge the qty of both the sets if the price is same but isImplied bool are different.
Current Output:
Price : 100 IsImplied : 0 Qty :10
Price : 200 IsImplied : 0 Qty : 20
As the price 100 and 200 were already present in the set the insertion of p3 and p4 is ignored.
Desired output:
Price : 100 IsImplied : 0 Qty :40 (10 + 30) (Qty is merged as P1 and P3 have same price but different isImplied values)
Price : 200 IsImplied : 0 Qty : 60 (20 + 40) (Qty is merged as P2 and P4 have same price but different isImplied values)
class PriceLevel
{
public:
    int price;
    int qty;
    bool isImplied;
    PriceLevel(int _price, int _qty, bool _isImplied)
    {
        price = _price;
        qty = _qty;
        isImplied = _isImplied;
    }
    friend bool operator<(const PriceLevel &p, const PriceLevel &q);
};
bool operator<(const PriceLevel &p, const PriceLevel &q)
{
    if(p.price < q.price)
    {
        return true;
    }
    else
    {
        return false;
    }
}
int main()
{
    std::set<PriceLevel> s1;
    PriceLevel p1(100,10, false);
    PriceLevel p2(200,20, false);
    PriceLevel p3(100,30, true);
    PriceLevel p4(200,40, true);
    s1.insert(p1);
    s1.insert(p2);
    s1.insert(p3);
    s1.insert(p4);
    set<PriceLevel>::iterator it = s1.begin();
    for(; it != s1.end(); it++)
    {
        cout << "Price: " << it->price << endl;
        cout << "Qty : " << it->qty << endl;
        cout << "IsImplied: " << it->isImplied << endl;
    }
}