Using directive to specify class alias in C++/CLI
In C#, there are three types of using directives:
using System; // Specify开发者_开发技巧 Namespace
using Diag = System.Diagnostics; // Specify Namespace Alias
using DBG = System.Diagnostics.Debug; // Specify Class Alias
In C++/CLI, I know the equivalents to the first two:
using namespace System;
namespace Diag = System::Diagnostics;
Is there any way to do the third one in C++/CLI?
Doing namespace DBG = System::Diagnostics::Debug;
gives error C2879: 'System::Diagnostics::Debug' : only an existing namespace can be given an alternative name by a namespace alias definition
The only alterntive I've come up with is #define DBG System::Diagnostics::Debug
, but I'd prefer a proper using directive, if available.
A C++ typedef will do the trick here.
typedef System::Diagnostics::Debug DBG;
精彩评论