I've come across lots of little technical problems before and have felt the impulse to create a new topic, but I thought they just didn't warrant their own thread.
So post your technical questions here if you don't want to start a new thread. Remember to be specific and if it's about programming try and include code to showcase your problem.
Ok, so I have this syntax in c++ to pass a function:
TestClass c;
Event e;
e.AddCallback<TestClass, &TestClass::TestFunction>(c);
// This is what the declaration of AddCallback looks like
template<class TObject, void (TObject::*TMethod)(int)>
void Event::AddCallback(TObject& argObj){};
This actually works but is there any way to be able to remove the reference operator(&) from the passed function in Event::AddCallback? I know it seems picky but I want to have the syntax as clean and simple as possible, and I really don't like passing pointers. I'd rather pass a reference and then get the pointer from within the function. And yes I realize I'm messing with raw pointers and not using const but I'm just trying to get it to work for the moment.
So the call will look like
e.AddCallback<TestClass, TestClass::TestFunction>(c);
Or possibly shorter/cleaner if possible.
And my second question is how would you go about making a unique id generator that can't overflow? Right now I just have unsigned longs that increment but values are never freed even when an object is destroyed. Even though longs have about 18
quintillion possible values there's still the improbable chance of an overflow. I was thinking about having each id be reusable but have a timestamp of when the last instance with that id died. Checks using the id with an older timestamps are invalidated. But then I realized there's the possibility of the timestamp overflowing... So yeah obviously I'm not use to lower level programming.