I have a map of objects but I need to do something with the constructor apparently? No clue how this is done. Apparently I need to overload the < operator? I have to yet to need to overload an operator until now so I really don't know how to approach this. Any help would be greatly appreciated.
The third template parameter is a function used to compare the keys to sort the map. std::less returns arg1 < arg2, so your types must overload that operator.
- Overload the operator. It's not hard, just look for an example or post the code and we can help you.
- Use a different compare object.
- Use a different type for the key.
The objects being stored are from my class GTexture.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Encapsulate sf::Texture to have ID reference etc. This is basically purely for organizational purposes
sf::Texture texture; // The actual sf::Texture
std::string nameRef; // I know I already have std::map for a key but this has other purposes so I still need it
GTexture(const std::string file, const std::string name); // Automatically get the file texture is located in and game texture name
I don't entirely get what you mean by that question. I'm just trying to get this class compatible with std::map. Googling it I've seen people say that you need to overload the < operator but I don't how you overload it. I've seen operators overloaded before but I don't know what to do with < .