1.. title:: clang-tidy - modernize-use-transparent-functors 2 3modernize-use-transparent-functors 4================================== 5 6Prefer transparent functors to non-transparent ones. When using transparent 7functors, the type does not need to be repeated. The code is easier to read, 8maintain and less prone to errors. It is not possible to introduce unwanted 9conversions. 10 11.. code-block:: c++ 12 13 // Non-transparent functor 14 std::map<int, std::string, std::greater<int>> s; 15 16 // Transparent functor. 17 std::map<int, std::string, std::greater<>> s; 18 19 // Non-transparent functor 20 using MyFunctor = std::less<MyType>; 21 22It is not always a safe transformation though. The following case will be 23untouched to preserve the semantics. 24 25.. code-block:: c++ 26 27 // Non-transparent functor 28 std::map<const char *, std::string, std::greater<std::string>> s; 29 30Options 31------- 32 33.. option:: SafeMode 34 35 If the option is set to `true`, the check will not diagnose cases where 36 using a transparent functor cannot be guaranteed to produce identical results 37 as the original code. The default value for this option is `false`. 38 39This check requires using C++14 or higher to run. 40