What are the benefits of free functions in an unnamed namespace over a class with private member functions?

see this question: Effective C++ Item 23 Prefer non-member non-friend functions to member functions and also C++ Member Functions vs Free Functions You should prefer free functions, in the extent that it promotes loose coupling. Consider making it a member function only if it works on the guts of your class, and that you consider … Read more

Should I prefer private member functions, or functions in an unnamed namespace? [duplicate]

In the semi large projects where I usually work (more than 2 million lines of code) I would ban private class functions if I could. The reason being that a private class function is private but yet it’s visible in the header file. This means if I change the signature (or the comment) in anyway … Read more

Are there any uses for unnamed namespaces in header files?

The only situation in which a nameless namespace in header can be useful is when you want to distribute code as header files only. For example, a large standalone subset of Boost is purely headers. The token ignore for tuples, mentioned in another answer is one example, the _1, _2 etc. bind placeholders are others.

How are unnamed namespaces superior to the static keyword? [duplicate]

You’re basically referring to the section ยง7.3.1.1/2 from the C++03 Standard, The use of the static keyword is deprecated when declaring objects in a namespace scope; the unnamed-namespace provides a superior alternative. Note that this paragraph was already removed in C++11. static functions are per standard no longer deprecated! Nonetheless, unnamed namespace‘s are superior to … Read more

Why should you prefer unnamed namespaces over static functions?

The C++ Standard reads in section 7.3.1.1 Unnamed namespaces, paragraph 2: The use of the static keyword is deprecated when declaring objects in a namespace scope, the unnamed-namespace provides a superior alternative. Static only applies to names of objects, functions, and anonymous unions, not to type declarations. Edit: The decision to deprecate this use of … Read more

Nested unnamed namespace?

Unnamed namespace could be considered as a normal namespace with unique name which you do not know. According to C++ Standard 7.3.1.1: An unnamed-namespace-definition behaves as if it were replaced by namespace unique { /* empty body */ } using namespace unique; namespace unique { namespace-body } where all occurrences of unique in a translation … Read more