I've got a bunch of my own objects which I've dutifully put inside my own namespace:
namespace my { struct foo final {}; /* etc. */}
Where should I put non-member non-friend functions (i.e., "global" utility routines) which take my types as parameters? Should I also put them in the my
namespace
namespace my { extern void f(const foo&); }
Or, is there an upside (or downside) to put them in the global namespace
extern void f(const my::foo&);
In either case, the argument to f
is my::foo
, so does it matter whether the function itself is actually named ::f()
or my::f()
?
Edit: note that I'm specifically not looking for "I like global" or "I like in the namespace" (or similar). Rather, I'm seeking specific technical reasons to prefer one approach over the other (assuming such differences actually exist). From a comment, it sounds like one (the?) factor to consider may be ADL behavior; are there others?