Hi I have a problem, I hope you can help me with.
I have a number, which I need to compare to some values.
I do not wish to go through all the values, and compare them individually, as I there are too many for it to be efficient.
Neither do I want to create an array with the size of the range of numbers, as it can anything from 0 UINT_MAX
So I am hoping that you might have a better solution.
Here is an example of what I have tried, but didn't work, because I get the values dynamicly
class Mother { public: Mother(){} ~Mother(){} template<int msg> inline void HandleMessage(){}; template<> inline void HandleMessage<10>() { std::cout<<"It works!\n"; } };
I think you'll have to be a bit more specific about what you're after, what needs to be compared, stuff like that. I don't know what to make of the code snippet, as it has no comparisons. off the top of my head, if you have ordered data, use a binary search so you don't have to compare every element, but again, without having any idea what kind of data you have or what kind of comparisons you need to make, it's hard to speculate.