maniacbug/StandardCplusplus

std::list<T> remove function is not working...

devenfan opened this issue · 2 comments

My Class Name: MyClass

Here is the code:

class MyCollection {

private:
    std::list<MyClass> m_list;

public:

    MyCollection() : m_list() {
    }

    void addMyClass(const MyClass & myClass) {
        m_list.push_back(myClass);
    }
    void addMyClass(const MyClass & myClass) {
        m_list.remove(myClass); //Error is occurred here
    }
}

Below is the error description:

StandardCplusplus-master/list:661: error: no match for 'operator==' in 'temp.std::list<T, Allocator>::iter_list::operator* [with T = MyClass, Allocator = std::allocator<MyClass>]() == value'

make: *** [MyLib.o] Error 1

You need to define bool MyClass::operator==(const MyClass& other). This is not a library bug