79773383

Date: 2025-09-24 07:24:38
Score: 1
Natty:
Report link

Since C++20, we now have access to std::string::starts_with.

If you intend on checking if std::string str1 starts with std::string str2, you can do the following:

if(str1.starts_with(str2))
{
  // code to execute if 
  // str1 does start with str2
}

For this specific case, it will perform better compared to std::string::find.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: ASr