Thanks for all of your answers.
@AzureBlaze
1. Wouldn't that be quite heavy for performance? Since every single of those instances has it's own list, and is used only shortly anyway..
2. Works, thanks!
@BitMaster
This would do everything I want; If it hadn't a fixed size. I wanted to create such a class exactly because of that: To avoid fixing myself on a fixed size (I mean, I probably won't use more than 4-5 flags anyway at once, so I could just use a 8bit integer, but I like to keep myself free of any restrictions...). Also I don't use boost so I won't be able to use boost::dynamic_bitset. I'll look at it for inspirations though, thanks!
@SeanMiddleditch
In this specific case I can't really allow myself to use enums, since the "flags" that are set are not really what you would expect from flags, but rather IDs generated on-the-fly; I just want to use flags because I really like the syntax (And how easy it is)
Your class looks quite complex, I'll try to understand it later :)
@Servant of the Lord
Exactly :). Although, now that I think of it, if one of the two flag-sets is empty, the intersection between the two should still return the non-empty flag-set... Which kind of defies the logic behind it. I'll explain what I actually want to do and why I want to use flagset further down this post.
@Krohm Heh, exactly, in reality using flags is probably a really bad idea. I just loved the simplicity that comes with using them, I guess. Here is what I really want to do:
In my EventHandler class, I'm able to trigger an event x, and I can hook some callback method to all events of type y. (Standard event-handler functionality I guess)
Since I want to also create some kind of scripting system later on, in order to define the entities of my game, which are all event-driven: Meaning their whole behaviour consists of callbacks being called from the eventhandler. But of course, I don't really want to let the callbacks be called by all events of type y; Let's take a collision-event as example: If I hook my entity-collision-callback to the collision event, it will be called everytime any collision happens in my game. So I need to apply some constraints, in order to have that event only called when the collision happens with this specific entity and another one.
I thought about applying these constraints with these flags:
When triggering the event, I specify the IDs of both objects colliding. Now, every callback that either has no constraints, or one of those specific constraints, will get called. Here a little pseudo-code, because I'm really bad at explaining stuff (I'll also use my UFlag class, even if it is probably the bad way of doing this.):
#define EIUF ... //Empty Integer UFlag
//When hooking into the event. Inside my entity-class
eventHandler->hookInto(EventType::Collision, myCollisionCallback, UFlag<int>(this->ID());
//When triggering the event:
eventHandler->triggerEvent(EventType::Collision, someArgument, UFlag<int>(collision.firstObject.ID(), collision.secondObject.ID()));
//If my entity has the same ID as one of the two in the collision event, it's callback will be called.
//If a callback is specified without constraints, it will get called, regardless of the IDs.
Depending on the event, the integer-flags could mean something else.
I hope I could make myself clear ...
Does anyone have an idea what I should use instead of those flags? As I already said, the thing is, I reaaally liked the syntax and everything.
Kind regards