__identifier (C++/CLI)

C++ キーワードを識別子として使用できるようにします。

すべてのプラットフォーム

構文

__identifier(C++_keyword)

解説

キーワードではない識別子での __identifier キーワードの使用は許可されていますが、スタイルの問題として、極力回避することをお勧めします。

Windows ランタイム

必要条件

コンパイラ オプション: /ZW

次の例では、C# で template という名前のクラスが作成され、DLL として配布されます。 template クラスを使用する C++/CLI プログラムでは、__identifier キーワードによって template が C++ の標準キーワードであることが隠されています。

// identifier_template.cs
// compile with: /target:library
public class template {
   public void Run() { }
}
// keyword__identifier.cpp
// compile with: /ZW
#using <identifier_template.dll>
int main() {
   __identifier(template)^ pTemplate = ref new __identifier(template)();
   pTemplate->Run();
}

共通言語ランタイム

解説

__identifier キーワードは、/clr コンパイラ オプションで有効です。

必要条件

コンパイラ オプション: /clr

次の例では、C# で template という名前のクラスが作成され、DLL として配布されます。 template クラスを使用する C++/CLI プログラムでは、__identifier キーワードによって template が C++ の標準キーワードであることが隠されています。

// identifier_template.cs
// compile with: /target:library
public class template {
   public void Run() { }
}
// keyword__identifier.cpp
// compile with: /clr
#using <identifier_template.dll>

int main() {
   __identifier(template) ^pTemplate = gcnew __identifier(template)();
   pTemplate->Run();
}

関連項目

.NET および UWP でのコンポーネント拡張
.NET および UWP でのコンポーネント拡張