42 lines · plain
1.. title:: clang-tidy - readability-redundant-string-init2 3readability-redundant-string-init4=================================5 6Finds unnecessary string initializations.7 8Examples9--------10 11.. code-block:: c++12 13 // Initializing string with empty string literal is unnecessary.14 std::string a = "";15 std::string b("");16 17 // becomes18 19 std::string a;20 std::string b;21 22 // Initializing a string_view with an empty string literal produces an23 // instance that compares equal to string_view().24 std::string_view a = "";25 std::string_view b("");26 27 // becomes28 std::string_view a;29 std::string_view b;30 31Options32-------33 34.. option:: StringNames35 36 Default is `::std::basic_string;::std::basic_string_view`.37 38 Semicolon-delimited list of class names to apply this check to.39 By default `::std::basic_string` applies to ``std::string`` and40 ``std::wstring``. Set to e.g. `::std::basic_string;llvm::StringRef;QString`41 to perform this check on custom classes.42