Every time I have some functionality which is in the direction of \"utility\", I end up wondering which option is the best. For instance, printing message structs (own or extern
I use struct with static functions, because it offers a slighly better isolation than non-member functions in namespaces (due to the avoidance of Koenig lookup).
To give an example of the thing I want to avoid:
namespace Foo
{
struct A
{
};
void f(const A& a) {}
}
void f(const Foo:A& a) { std::cout << "AAA"; }
int main(void)
{
Foo::A a;
f(a); // calls Foo:f
return 0;
}