mercredi 22 juillet 2015

How to insert a reference to a multimap?

I have a class Foo that contains a multimap with an unsigned long and a reference to a Bar class.

I'm getting the error "no matching function to call multimap, etc".

What is wrong on my insert into the multimap?

[header file]

class Foo
{
public:

    Foo();

    ~Foo();

    void set(const unsigned long var1, const Bar& var2);

private:

    struct map_sort
    {
        bool operator()(const unsigned long& e1, const unsigned long& e2) const
        {
            return (e2 < e1);
        }
    };

    std::multimap<unsigned long,Bar&, map_sort> m_map;
};

[source file]

void Foo::set(const unsigned long var1, const Bar& var2)
{
    m_map.insert(var1,rtime); //<-- ERROR!!!!!!!!
}

Aucun commentaire:

Enregistrer un commentaire