# コード生成

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/ja-jp/help/clion/llms.txt).

> **TL;DR**
> `コード | 生成する`  または `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Alt+Insert` (Visual Studio), `⌘ ⌃ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌘ ⌃ N` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS))
>
>
>
> 設定： `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))  `設定 | エディター | ファイルとコードのテンプレート`

CLion provides multiple ways to generate common code constructs and recurring elements, which helps you increase productivity. これには、新しいファイルの作成時に使用される [ファイルテンプレート](using-file-and-code-templates.html)、コンテキストに応じて異なる方法で適用されるカスタムまたは定義済みの [ライブテンプレート](using-live-templates.html)、各種ラッパー、文字の自動ペアリングなどがあります。

生成   メニューは、コード内に標準的なコード構造をすばやく作成できます。 Depending on the current context, the caret position, or selected code, CLion gives you a list of constructs to be generated.

![生成メニュー](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generatemenu_2.png)

Procedure: 生成ポップアップを呼び出す

次のいずれかのオプションを使用します。

* `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Alt+Insert` (Visual Studio), `⌘ ⌃ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌘ ⌃ N` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)) を押す。

* メインメニューから  `コード | 生成する`  を呼び出します。

* エディターを右クリックし、コンテキストメニューから   生成   を選択します。

Procedure: コンストラクターを生成

1. 生成   ポップアップから   コンストラクター   を選択します。

2. If the class contains fields, select the fields to be initialized:

![コンストラクターを生成](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generateconstructor_dialog.png)

3. If the   インプレースで生成   checkbox is selected, the template constructor will be generated in the  `public`  area of the class, otherwise the code will be placed in the corresponding  `cpp`  file.

![その場で生成されたコンストラクター](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generateconstructor_result.png)

Procedure: getter および setter を生成

1. 生成   ポップアップから   Getter   、   Setter   、   Getter と Setter   を選択します。

2. Select the fields to generate the getters/setters for:

![getter および setter を生成](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generategettersetter_dialog.png)

3. If the   インプレースで生成   checkbox is selected, the getters/setters will be generated in the  `public`  area of the class, otherwise the code will be placed in the corresponding  `cpp`  file.

![Getter および setter はインプレースで生成](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generategettersetter_results.png)

Procedure: 等値演算子を生成する

このアクションは、選択されたフィールドを使用して現在のクラスのオブジェクトを比較する  `operator==`  および  `operator!=`  関数を生成します。

1. 生成   ポップアップから   等価演算子   を選択します。

2. Select the fields to be used and set addition options:

![等値演算子を生成する](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generateoperators_equality_dialog.png)

3. If the   インプレースで生成   checkbox is selected, the operator functions will be generated in the  `public`  area of the class, otherwise the code will be placed in the corresponding  `cpp`  file.

![インプレースで生成された等価演算子](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generateoperators_equality_result.png)

Procedure: 関係演算子を生成する

このアクションは、選択したフィールドを使用して現在のクラスのオブジェクトを比較する  `operator<`  、  `operator>`  、  `operator<=`  、  `operator>=`  関数を生成します。

1. 生成   ポップアップから   比較演算子   を選択します。

2. Select the fields to be used and set addition options:

![関係演算子を生成する](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generateoperators_relational_dialog.png)

3. If the   インプレースで生成   checkbox is selected, the operator functions will be generated in the  `public`  area of the class, otherwise the code will be placed in the corresponding  `cpp`  file.

![インプレースで生成された関係演算子](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generateoperators_relational_result.png)

Procedure: ストリーム出力演算子を生成する

このアクションは、選択したフィールドを使用して現在のクラスのオブジェクトのストリーム出力を生成する方法を定義する挿入演算子  `operator<<`  を生成します。

1. 生成   ポップアップから   ストリーム出力操作   を選択します。 使用するフィールドを選択します。

2. If the   インプレースで生成   checkbox is selected, the operator function will be generated in the  `public`  area of the class, otherwise the code will be placed in the corresponding  `cpp`  file.

![インプレースで生成されたストリーム出力演算子](https://resources.jetbrains.com/help/img/idea/2026.3/cl_generateoperators_streamoutput_result.png)

