0

Like in the following example:

#include <glm/glm.hpp>

int main()
{
    glm::vec3 a;
    dot(a, a);
}

Without using the glm namespace anywhere, calling its dot function compile and works (altough it does not appears in the intellisense).

How can it be possible?

Severin Pappadeux
  • 18,636
  • 3
  • 38
  • 64

1 Answers1

0

During overload resolution associated namespaces are searched. This argument-dependent look-up (ADL). The namespaces associated with a in the call of dot(a, a) depend on how glm::vec3 is defined. Assuming it is defined in glm (rather than namespace glm merely including a using-declaration or a typedef for a type defined elsewhere), names from glm are found. Additional namespaces may be searched if vec3 inherits from class in other namespaces or is actually a class template instantiated with types defined in other namespaces.

Dietmar Kühl
  • 150,225
  • 13
  • 225
  • 380