51 lines · plain
1.. title:: clang-tidy - modernize-min-max-use-initializer-list2 3modernize-min-max-use-initializer-list4======================================5 6Replaces nested ``std::min`` and ``std::max`` calls with an initializer list7where applicable.8 9For instance, consider the following code:10 11.. code-block:: cpp12 13 int a = std::max(std::max(i, j), k);14 15The check will transform the above code to:16 17.. code-block:: cpp18 19 int a = std::max({i, j, k});20 21Performance Considerations22==========================23 24While this check simplifies the code and makes it more readable, it may cause25performance degradation for non-trivial types due to the need to copy objects26into the initializer list.27 28To avoid this, it is recommended to use `std::ref` or `std::cref` for29non-trivial types:30 31.. code-block:: cpp32 33 std::string b = std::max({std::ref(i), std::ref(j), std::ref(k)});34 35Options36=======37 38.. option:: IncludeStyle39 40 A string specifying which include-style is used, `llvm` or `google`. Default41 is `llvm`.42 43.. option:: IgnoreNonTrivialTypes44 45 A boolean specifying whether to ignore non-trivial types. Default is `true`.46 47.. option:: IgnoreTrivialTypesOfSizeAbove48 49 An integer specifying the size (in bytes) above which trivial types are50 ignored. Default is `32`.51