1. Variables & Types (変数と型)
-
modernize-use-auto -
EN: Uses
autofor variable declarations where the type is already explicitly stated or obvious (e.g., iterators,new). -
JP: 型が明白または右辺で明示されている変数の宣言に
autoを使用します(例: イテレータ、newによる割り当て)。 -
modernize-use-bool-literals -
EN: Replaces integer literals (0, 1) with boolean literals (
false,true) forbooltypes. -
JP:
bool型に対して、整数リテラル (0, 1) を真偽値リテラル (false,true) に置き換えます。 -
modernize-use-using -
EN: Replaces old-style C
typedefwith C++11usingaliases. -
JP: 従来の C 言語スタイルの
typedefを C++11 のusingエイリアスに置き換えます。 -
modernize-use-trailing-return-type -
EN: Rewrites function signatures to use C++11 trailing return types (e.g.,
auto func() -> int;). Note: Many codebases disable this as it is a stylistic choice. -
JP: 関数のシグネチャを C++11 の後置戻り値型 (
auto func() -> int;の形式) を使用するように書き換えます。※好みが分かれるため無効にされることが多いです。 -
modernize-type-traits -
EN: Replaces
typename std::...::typeorstd::...::valuewith C++14/17 variable and alias templates (std::..._tandstd::..._v). -
JP: 従来の型特性(traits)を C++14/17 のエイリアス/変数テンプレート (
_tや_v) に置き換えます。
2. Classes & Objects (クラスとオブジェクト)
-
modernize-use-default-member-init -
EN: Converts constructor initializers to C++11 in-class default member initializers.
-
JP: コンストラクタでの初期化を、C++11 のクラス内デフォルトメンバー初期化に変換します。
-
modernize-use-equals-default -
EN: Uses
= defaultinstead of empty default constructors, destructors, or copy/move operators. -
JP: 空のデフォルトコンストラクタやデストラクタなどの代わりに
= defaultを使用します。 -
modernize-use-equals-delete -
EN: Uses
= deleteinstead of unimplemented private special member functions to prevent copying. -
JP: コピーを禁止するために未実装の private 関数を用意する古い手法の代わりに、
= deleteを使用します。 -
modernize-use-override -
EN: Adds the
overridespecifier to overriding virtual functions to ensure compile-time safety. -
JP: オーバーライドする仮想関数に
override指定子を追加し、コンパイル時の安全性を高めます。 -
modernize-use-designated-initializers(Newer) -
EN: Uses C++20 designated initializers (
{.x = 1, .y = 2}) for struct initialization. -
JP: 構造体の初期化に C++20 の指示初期化子 (designated initializers:
{.x = 1, .y = 2}) を使用します。 -
modernize-return-braced-init-list -
EN: Replaces explicit type construction in
returnstatements with braced initializer lists{}. -
JP:
return文での明示的な型の構築を、波括弧による初期化リスト{}に置き換えます。
3. Memory & Pointers (メモリとポインタ)
-
modernize-use-nullptr -
EN: Replaces C-style
NULLor0pointers with C++11nullptr. -
JP: C言語スタイルの
NULLや0ポインタを C++11 のnullptrに置き換えます。 -
modernize-make-shared -
EN: Replaces
std::shared_ptrcreation vianewwith the safer and more efficientstd::make_shared. -
JP:
newを使ったstd::shared_ptrの作成を、安全で効率的なstd::make_sharedに置き換えます。 -
modernize-make-unique -
EN: Replaces
std::unique_ptrcreation vianewwithstd::make_unique(C++14). -
JP:
newを使ったstd::unique_ptrの作成を、std::make_unique(C++14) に置き換えます。 -
modernize-replace-auto-ptr -
EN: Replaces the deprecated (and removed)
std::auto_ptrwithstd::unique_ptr. -
JP: 非推奨(現在は削除済み)の
std::auto_ptrをstd::unique_ptrに置き換えます。
4. Loops, Algorithms & STL (ループ・アルゴリズム・STL)
-
modernize-loop-convert -
EN: Converts traditional
for (int i = 0; ...)and iterator loops to C++11 range-basedforloops. -
JP: 従来のインデックスやイテレータを使った
forループを、C++11 の範囲ベース (range-based)forループに変換します。 -
modernize-avoid-bind -
EN: Replaces
std::bindwith C++14 lambda expressions for better readability and performance. -
JP: 読みやすさとパフォーマンス向上のため、
std::bindを C++14 のラムダ式に置き換えます。 -
modernize-avoid-c-arrays -
EN: Replaces C-style arrays (
int arr[10]) withstd::arrayorstd::vector. -
JP: C言語スタイルの配列 (
int arr[10]) をstd::arrayやstd::vectorに置き換えます。 -
modernize-use-emplace -
EN: Replaces
push_back/insertwithemplace_back/emplacewhere it avoids unnecessary temporary object creation. -
JP: 不要な一時オブジェクトの作成を避けられる場合、
push_backやinsertをemplace_backやemplaceに置き換えます。 -
modernize-shrink-to-fit -
EN: Replaces the old "copy-and-swap" trick used to clear capacity with
std::vector::shrink_to_fit(). -
JP: メモリ解放のための古い「コピー&スワップ」テクニックを
std::vector::shrink_to_fit()に置き換えます。 -
modernize-replace-random-shuffle -
EN: Replaces deprecated
std::random_shufflewith C++11std::shuffle. -
JP: 非推奨の
std::random_shuffleを C++11 のstd::shuffleに置き換えます。 -
modernize-use-transparent-functors -
EN: Prefers transparent functors (e.g.,
std::less<>) over explicitly typed ones (std::less<int>). -
JP: 明示的に型指定された関数オブジェクト (
std::less<int>) より、透過的な関数オブジェクト (std::less<>) を優先します。
5. String Formatting & Output (文字列・出力)
-
modernize-raw-string-literal -
EN: Converts heavily escaped string literals into C++11 raw string literals (
R"(...)"). -
JP: エスケープ文字が多い文字列リテラルを、C++11 の生文字列 (raw string) リテラル (
R"(...)") に変換します。 -
modernize-use-starts-ends-with(C++20) -
EN: Replaces verbose
findorcomparemethods with C++20starts_withandends_with. -
JP: 冗長な
findやcompareメソッドを C++20 のstarts_withおよびends_withに置き換えます。 -
modernize-use-std-format(C++20) -
EN: Converts old string formatting logic (like
absl::StrFormat) to C++20std::format. -
JP: 古い文字列フォーマットを C++20 の
std::formatに変換します。 -
modernize-use-std-print(C++23) -
EN: Replaces C-style
printfwith C++23std::print. -
JP: C言語スタイルの
printfを C++23 のstd::printに置き換えます。
6. Macros & Preprocessor (マクロ・プリプロセッサ)
-
modernize-macro-to-enum -
EN: Replaces groups of adjacent integer macros (
#define A 1,#define B 2) with C++11 scoped enums (enum class). -
JP: 隣接する整数のマクログループ (
#define A 1など) を C++11 のスコープ付き列挙型 (enum class) に置き換えます。 -
modernize-replace-disallow-copy-and-assign-macro -
EN: Replaces old Google-style
DISALLOW_COPY_AND_ASSIGNmacros with explicitly deleted special member functions. -
JP: 古い Google スタイルの
DISALLOW_COPY_AND_ASSIGNマクロを、明示的に delete された特殊メンバー関数に置き換えます。 -
modernize-deprecated-headers -
EN: Replaces C standard library headers (e.g.,
<math.h>,<stdio.h>) with their C++ equivalents (<cmath>,<cstdio>). -
JP: C言語の標準ライブラリヘッダ (
<math.h>,<stdio.h>など) を C++ 用のヘッダ (<cmath>,<cstdio>) に置き換えます。
7. Modern C++ Features & Attributes (モダン機能・属性)
-
modernize-concat-nested-namespaces -
EN: Replaces nested namespaces (
namespace A { namespace B {) with C++17 concise syntax (namespace A::B {). -
JP: ネストされた名前空間 (
namespace A { namespace B {) を C++17 の簡潔な構文 (namespace A::B {) に置き換えます。 -
modernize-use-nodiscard -
EN: Adds the
[[nodiscard]]attribute to functions that return values representing state, errors, or allocated memory. -
JP: 状態、エラー、または割り当てられたメモリを返す関数(無視すべきでない戻り値)に
[[nodiscard]]属性を追加します。 -
modernize-use-noexcept -
EN: Replaces deprecated
throw()exception specifications with the C++11noexceptspecifier. -
JP: 非推奨の
throw()例外指定を C++11 のnoexcept指定子に置き換えます。 -
modernize-use-uncaught-exceptions -
EN: Replaces the deprecated
std::uncaught_exception()with C++17std::uncaught_exceptions(). -
JP: 非推奨の
std::uncaught_exception()を C++17 のstd::uncaught_exceptions()(複数形) に置き換えます。 -
modernize-use-constraints(C++20) -
EN: Replaces SFINAE (
std::enable_if) with C++20 requires clauses (Concepts). -
JP: SFINAE (
std::enable_ifなど) を C++20 の requires 句 (コンセプト) に置き換えます。 -
modernize-use-std-numbers(C++20) -
EN: Replaces math constant macros (like
M_PI) with C++20<numbers>library constants (likestd::numbers::pi). -
JP: 数学定数のマクロ (
M_PIなど) を C++20 の<numbers>ライブラリ定数 (std::numbers::piなど) に置き換えます。
8. Miscellaneous (その他)
-
modernize-pass-by-value -
EN: Suggests replacing const-reference parameters with pass-by-value and
std::movewhen the parameter is unconditionally copied inside the function. -
JP: 関数内で必ずコピーされるパラメータに対し、const参照渡しではなく値渡しと
std::moveを使用するように提案します。 -
modernize-redundant-void-arg -
EN: Removes redundant
voidfrom C-style function declarations without parameters (int f(void)->int f()). -
JP: 引数のない関数の宣言から、C言語スタイルの不要な
voidを削除します (int f(void)->int f())。 -
modernize-unary-static-assert -
EN: Removes the redundant empty string message from C++17 single-argument
static_assert. -
JP: C++17 の単一引数
static_assertから、不要な空のメッセージ文字列""を削除します。 -
modernize-min-max-use-initializer-list -
EN: Replaces nested
std::minorstd::maxcalls with a single call using an initializer list (e.g.,std::max({a, b, c})). -
JP: ネストされた
std::minやstd::maxの呼び出しを、初期化子リストを使用した単一の呼び出し(例:std::max({a, b, c}))に置き換えます。 -
modernize-deprecated-ios-base-aliases -
EN: Replaces deprecated
std::ios_basealiases (likestd::ios_base::io_state) with newer, standard ones. -
JP: 非推奨の
std::ios_base関連の型エイリアスを標準の新しいものに置き換えます。