Hi everyone. I want to get the int compare operator <, =, > as functions.
If I can get them as function, I can treat them as other function's parameter for call back.
Is that possible?
Edit:
I used to do such thing a lot at functional programming language.
But have operator as parameter question in C++.
If I want to implement these things, they are super easy:
probably not.
this is built into all cpu, and so the compiler is using the JNE or something CPU instruction.
you will have to write your own.
think about your design again. If possible, avoid this idea: you are probably looking to introduce java-like slowness into your code here, and it may be avoidable.
Thanks jonnin.
The reason why I am asking, is also concerned with your answer.
I thought these functions implemented by me is not so fast as the normal >, = , < .
Do you see some places to improve the performance?
they will not be as fast if you make your own.
if you are doing a LOT (billion+) of them, it will begin to be an issue. Is it going to be an issue with your project?
If so, the answer is 'can you do it without a call-back at all' ?
if not, you may be stuck.
if you can, just avoid the call-back overhead and let the CPU do the CPU's work.