Skip to content

Commit b5dee9a

Browse files
author
Daniel Kroening
committed
C++20 replacements for has_suffix/has_prefix
This clarifies the intended meaning of the existing functions.
1 parent 6d21a4a commit b5dee9a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/util/prefix.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include <string>
1414

15+
// C++20 will have std::string::starts_with
16+
1517
inline bool has_prefix(const std::string &s, const std::string &prefix)
1618
{
1719
return s.compare(0, prefix.size(), prefix)==0;

src/util/suffix.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include <string>
1414

15+
// C++20 will have std::string::ends_with
16+
1517
inline bool has_suffix(const std::string &s, const std::string &suffix)
1618
{
1719
if(suffix.size()>s.size())

0 commit comments

Comments
 (0)