I have a class which defines such function: std::string operator()() const;
How to make a function with another name, which would work like this one? I'd like it to do exactly what operator() does, so if you change operator() this would also be changed. And also by alias I mean sth, that doesn't change machine code, like inline functions (though they are not always guaranteed to work, so they are no-no).
Write now you can call operator() on object of the class. I want to give that function another name: to_string. how to do it, so that it doesn't affect the performance? If i wrote std::string to_string() const{ returnthis->operator(); }
it could be inlined and behave like I want, directly, but some compilers might decide to call this function, then the proper one.
The compiler doesn't just inline functions at random. This is a perfect example where inline should be beneficial and I would be surprised if not all compilers worth their salt inline that function if you make it an inline function.
I think you should stop being too paranoid about this. There is a big chance you wouldn't even notice the extra function call even if it did happen. You could always go back and optimize the code later if you find it is a bottleneck.
Maybe it's true, that I'm a little bit insane on optimizing. Thanks Peter87, I'm going to use that for now, but I hope somebody knows the technique I described.