SFML community forums

Help => System => Topic started by: NobodyNothing on February 18, 2012, 05:33:35 am

Title: sf::Vector3i not working in std::pair?
Post by: NobodyNothing 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 (http://www.sfml-dev.org/wiki/en/sources/resource_manager_hiura) one from the wiki.

If anyone knows what could be causing the error, I would appreciate any help you could give
Title: sf::Vector3i not working in std::pair?
Post by: Laurent 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.
Title: sf::Vector3i not working in std::pair?
Post by: NobodyNothing on February 19, 2012, 12:59:44 am
Thanks! Got it working now :)