I have a class, which extensively uses members of a particular namespace, like this:
class Entity {
using namespace glm;
public:
Entity(vec3 position, vec3 direction, vec3 upVector, vec3 velocity, float speed = 0.0f);
Entity(vec3 position, vec3 direction, vec3 upVector);
Entity(vec3 position, vec3 direction);
virtual ~Entity() {}
vec3 position() { return this->pos; }
vec3 direction() { return this->dir; }
vec3 upVector() { return this->upVec; }
vec3 velocity() { return this->vel; }
float speed() { return this->spd; }
// lots of other methods
protected:
vec3 pos;
vec3 dir;
vec3 upVec;
vec3 vel;
float spd;
// lots of other members
};
I just discovered using namespace
is not allowed inside a class, so i can't do it this way.
I can see only 2 options how to get out of this, both of which are stupid:
- repeat the
namespace_name::
(glm::) before each usage of members (vec3, vec4, mat3, ...) - declare
using namespace
outside of the class and force this namespace to everyone, who includes my header
Is there a nicer/cleaner way, how to solve this problem?