我一直在做C++很长一段时间,但我今天早上刚刚遇到了一个问题,我无法给出答案:“是否可以在C++中为命名空间创建别名?”重命名命名空间
让我举个例子。比方说,我有以下标题:
namespace old
{
class SomeClass {};
}
其中,原因不详必须成为:
namespace _new
{
namespace nested
{
class SomeClass {}; // SomeClass hasn't changed
}
}
现在,如果我有一个旧的代码库是指SomeClass
,我可以很快(和dirtily )加入“修复”的变化:
namespace old
{
typedef _new::nested::SomeClass SomeClass;
}
但是,有没有办法从_new::nested
进口一切我nto old
而不必typedef
明确每个类型?
类似于Python的东西import * from ...
。
谢谢。
'new'可能是名称空间名称的一个坏例子。 ;) – Xeo 2011-05-24 10:00:58