File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ .. title :: clang-tidy - modernize-use-starts-ends-with
2+
3+ modernize-use-starts-ends-with
4+ ==============================
5+
6+ Checks for common roundabout ways to express ``starts_with `` and ``ends_with ``
7+ and suggests replacing with the simpler method when it is available. Notably,
8+ this will work with ``std::string `` and ``std::string_view ``.
9+
10+ Covered scenarios:
11+
12+ ==================================================== =====================
13+ Expression Replacement
14+ ---------------------------------------------------- ---------------------
15+ ``u.find(v) == 0 `` ``u.starts_with(v) ``
16+ ``u.rfind(v, 0) != 0 `` ``!u.starts_with(v) ``
17+ ``u.compare(0, v.size(), v) == 0 `` ``u.starts_with(v) ``
18+ ``u.substr(0, v.size()) == v `` ``u.starts_with(v) ``
19+ ``v != u.substr(0, v.size()) `` ``!u.starts_with(v) ``
20+ ``u.compare(u.size() - v.size(), v.size(), v) == 0 `` ``u.ends_with(v) ``
21+ ``u.rfind(v) == u.size() - v.size() `` ``u.ends_with(v) ``
22+ ==================================================== =====================
You can’t perform that action at this time.
0 commit comments