Reputation: 1319
So I'm wrapping GL Mathematics library (GLM) to replace my game engine's current vector mathematics system. I would like to keep all the naming conventions I've used so far.
For renaming classes, this is easy:
#include <glm/glm.hpp>
namespace BromineEngine {
typedef glm::vec4 Vec4f;
...
}
However, function are more complicated. I need to make sure the function is still in the BromineEngine
namespace.
I thought about doing a macro inside the namespace, but afaik macros don't respect namespaces. I could also just make templated functions that forward the arguments, but this seems slow.
Any help?
Upvotes: 0
Views: 73
Reputation: 339
You can use inline functions to get what you want. For example, with a function with signature bool(int, int)
inline bool rename_f(int i, int j) {
return glm::f(i, j);
}
The compiler will optimize (it won't necessarily optimize any inlined functions, but for simple ones like that, it is almost guaranteed) the code and replace your function call with its body everywhere in your code.
Upvotes: 3