C++ Logo

sg10

Advanced search

[SG10] N4230 Nested namespace definition

From: Nelson, Clark <clark.nelson_at_[hidden]>
Date: Mon, 23 Mar 2015 22:24:07 +0000
The name __cpp_nested_namespace_definitions seems pretty obvious and
non-controversial.

But I don't think we've actually considered whether a new macro would be
justified. How would a reasonable person write code that works both with and
without this feature?

#if __cpp_nested_namespace_definitions
#define NND(x) x::
#else
#define NND(x)
#endif

#if !__cpp_nested_namespace_definitions
namespace X { namespace Y {
#endif
void NND(X::Y) f()
{
}
#if !__cpp_nested_namespace_definitions
}}
#endif

Is it plausible that someone would write code like that? If they cared about
portability to C++14, would they be more likely to just ignore this new
feature, and write their code the old way?

Clark

Received on 2015-03-23 23:24:12