1.. title:: clang-tidy - modernize-min-max-use-initializer-list 2 3modernize-min-max-use-initializer-list 4====================================== 5 6Replaces nested ``std::min`` and ``std::max`` calls with an initializer list 7where applicable. 8 9For instance, consider the following code: 10 11.. code-block:: cpp 12 13 int a = std::max(std::max(i, j), k); 14 15The check will transform the above code to: 16 17.. code-block:: cpp 18 19 int a = std::max({i, j, k}); 20 21Performance Considerations 22========================== 23 24While this check simplifies the code and makes it more readable, it may cause 25performance degradation for non-trivial types due to the need to copy objects 26into the initializer list. 27 28To avoid this, it is recommended to use `std::ref` or `std::cref` for 29non-trivial types: 30 31.. code-block:: cpp 32 33 std::string b = std::max({std::ref(i), std::ref(j), std::ref(k)}); 34 35Options 36======= 37 38.. option:: IncludeStyle 39 40 A string specifying which include-style is used, `llvm` or `google`. Default 41 is `llvm`. 42 43.. option:: IgnoreNonTrivialTypes 44 45 A boolean specifying whether to ignore non-trivial types. Default is `true`. 46 47.. option:: IgnoreTrivialTypesOfSizeAbove 48 49 An integer specifying the size (in bytes) above which trivial types are 50 ignored. Default is `32`.