Hi, I'm just wondering how I'd implement some specific error checking code. If I have for example, some key bindings in a namespace of type sf::KeyboardKey, which I equate to some of SFML's key enumerations, how can I check that I am passing a binding and not SFML's predefined enum to a function? (to avoid redefining SFML's enumerations by accident!)
Some code to demonstrate what I mean clearly...
Say I have a binding namespace like this:
namespace kb
{
sf::Keyboard::Key moveLeft = sf::Keyboard::A;
// etc...
}
And call a function like this (yes it's rather trivial, but the point remains):
void KeyBindings::SetKeyBinding(sf::Keyboard::Key &binding, sf::Keyboard::Key newKey)
{
// check binding is a binding and not a predefined key
if(binding is a binding)
{
binding = newKey;
}
}
I considered using an enumerated list for the bindings, but realised they're supposed to be rvalues, when I need lvalues. And the obvious problem with checking if binding == moveLeft (or whatever) is that binding == sf::Keyboard::A too
.
Cheers.