我有一个大型的软件框架,目前生活在一个通用的命名空间。最近,我将一些类移入嵌套的名称空间,但为了暂时保持向后兼容性,我需要将名称保留在全局名称空间中。到目前为止,我使用using
:从嵌套命名空间注入类型:Typedef或使用?
namespace framework {
namespace IO {
struct IStream;
}
#if COMPATIBILITY
using IO::IStream;
#endif
}
但是,我同样可以使用typedef IO::IStream IStream;
。使用typedef
而不是using
有什么优势/劣势?
但要小心AD''used'_函数重载;使用非类型可能不完全按照你的想法(http://stackoverflow.com/questions/2953684/why-doesnt-adl-find-function-templates) – sehe
可能的重复[有什么区别typedef和使用?](http://stackoverflow.com/questions/7657710/what-are-the-differences-between-typedef-and-using) –