Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Event::KeyEvent operator<  (Read 2806 times)

0 Members and 1 Guest are viewing this topic.

Kernelpanic

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • http://eisenholz.bplaced.net
[Solved] Event::KeyEvent operator<
« 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Solved] Event::KeyEvent operator<
« Reply #1 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.
Laurent Gomila - SFML developer

Kernelpanic

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
    • http://eisenholz.bplaced.net
[Solved] Event::KeyEvent operator<
« Reply #2 on: June 02, 2008, 08:51:57 pm »
Yeah, it works fine!
Thank you, it is a very nice forum!