SFML community forums

Help => Window => Topic started by: Kernelpanic on June 01, 2008, 10:47:37 pm

Title: [Solved] Event::KeyEvent operator<
Post by: Kernelpanic on June 01, 2008, 10:47:37 pm
Code: [Select]

#ifndef SFEKE_OPERATOR_LESS

#define SFEKE_OPERATOR_LESS

namespace sf
{
bool operator<(const Event::KeyEvent& a, const Event::KeyEvent& b)
{
if(static_cast<int>(a.Code) < static_cast<int>(b.Code))
return true;
if(static_cast<int>(a.Code) > static_cast<int>(b.Code))
return false;
if(a.Alt < b.Alt)
return true;
if(a.Alt > b.Alt)
return false;
if(a.Control < b.Control)
return true;
if(a.Control > b.Control)
return false;
if(a.Shift < b.Shift)
return true;
return false;
}
};

#endif


I want to use an Event::KeyEvent as Keytype in a multimap.
So I have defined this operator<.
But I get this g++-Link-Error:
Quote

/home/Jonathan2/Desktop/C++/Linuwokakerox/src/Utils.cpp:35: multiple definition of `sf::operator<(sf::Event::KeyEvent const&, sf::Event::KeyEvent const&)'



What could I do?
Title: [Solved] Event::KeyEvent operator<
Post by: Laurent on June 02, 2008, 10:32:29 am
Define your function in a cpp file, or make it inline if you want to keep it in a header.
Title: [Solved] Event::KeyEvent operator<
Post by: Kernelpanic on June 02, 2008, 08:51:57 pm
Yeah, it works fine!
Thank you, it is a very nice forum!