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

Author Topic: sf::Vector3i not working in std::pair?  (Read 3910 times)

0 Members and 1 Guest are viewing this topic.

NobodyNothing

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::Vector3i not working in std::pair?
« on: February 18, 2012, 05:33:35 am »
I'm receiving this error:
Quote
Error   1   error C2678: binary '<' : no operator found which takes a left-hand operand of type 'const sf::Vector3i' (or there is no acceptable conversion)   c:\program files (x86)\microsoft visual studio 10.0\vc\include\xfunctional   125


The only place in my game I'm using a const Vector3i (and non-coincidentally the place I was working on when this error was introduced) is in a TileManager class, subclassed from a Templated ResourceManager

Code: [Select]

//Shortcut for string & Tile reference & location
typedef std::pair<sf::Vector3i, Tile&> TileInfo;

class TileManager : public sftools::ResourceManager<Tile, TileInfo, sf::Vector3i>
{
public:
const sf::Vector3i& Load(const TileInfo& locator)
{
// Add the Texture to the manager
Add(locator.first, locator.second);
// Return the XYZ location
return locator.first;
}
};


The ResourceManger base class I'm deriving TileManager from is this one from the wiki.

If anyone knows what could be causing the error, I would appreciate any help you could give

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Vector3i not working in std::pair?
« Reply #1 on: February 18, 2012, 09:03:26 am »
A type must have an operator< to be usable as a key in a std::map (because items are ordered by key in such a container). So either write this operator for sf::Vector3i, use a custom functor, or use another key type.
Laurent Gomila - SFML developer

NobodyNothing

  • Newbie
  • *
  • Posts: 10
    • View Profile
sf::Vector3i not working in std::pair?
« Reply #2 on: February 19, 2012, 12:59:44 am »
Thanks! Got it working now :)

 

anything