There's resistance against using the same name in a namespace and a type inside that namespace. Why? What is the actual problem with this code? Is the 'foo::foo' looking too much like a constructor definition (in that context)? Isn't it great how the call to 'bar' has a clear relation to 'foo'?
Why is it considered bad practice that shouldn't pass code review?

#cpp #cplusplus #WG21 #cpp26 #namingThingsIsHard

@mkretz
Move on - nothing to see here!

Fine with me, I can't see a problem here.

@mkretz
As a general nitpick on naming:

I think of classes/templates/types as "things" and of namespaces as "groups". Based on that, it would be a bit odd to have the same name for both.
But if you have good arguments in your specific case - why not 🤷

@dermojo Yes, but what if the namespace groups all functions, traits, concepts, and related types centered around one "name-giving" type. E.g. boost::histogram::histogram<...>, or my (obvious) candidate std::simd::simd<T> ? Would a good design invent a new name for the namespace? Or is that more noise than help?
@mkretz
I think these are good examples for when not to choose an arbitrary different name. The namespace is the name of the library, and if this library has one (major) component, it's IMO fine if they are the same.