As others have said, if you really want to limit the scope of a function to a cpp file, you should put it in a namespace, for example
namespace
However, it would seem that the maintenance problem should have the same function with the same body (that is, they both do the same) in two different places - copy / paste the style. If two different functions have the same name but different bodies, then this is also a problem waiting for this to happen.
Obviously, you have performance issues (hence built-in), but it would be best to have a function written in one place! At a minimum, put it in the header file (in the anonymous namespace), which is included where you need it. In fact, you should do it “cleanly” and then return to specific performance approaches when your profiler tells you.
Greetings
Michael
source share