我有一個大型的軟件框架,目前生活在一個通用的命名空間。最近,我將一些類移入嵌套的名稱空間,但爲了暫時保持向後兼容性,我需要將名稱保留在全局名稱空間中。到目前爲止,我使用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) –