Even though using namespace
is the laziest (and therefore the most tempting) solution, it's often not a good idea. Besides what Luchian says about function declarations being ambiguous (someone new to the project wouldn't know if that is standalone function or one in the namespace), and the fact that you might introduce a name in the namespace later, clashing with one you are using now, I have another reason why I'd suggest using the third method.
Using the third method, you give your code more consistency. If A
is inside B
, you would always define it with A::B
. If A
is a class and B
a function in the class, you would write type A::B(args)
. If A
is a class and B
a static member, you would again write type A::B = value
. Now A
is a namespace, but it's still the same concept: B
is defined inside A
, therefore it is more consistent to again use A::B
.
(There is an added bonus of search-ability if your editor is e.g. ViM)