Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/util/infix.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ Author: Chris Smowton, chris.smowton@diffblue.com
#ifndef CPROVER_UTIL_INFIX_H
#define CPROVER_UTIL_INFIX_H

#include <string>
#include <string_view>

inline bool has_infix(
const std::string &s,
const std::string &infix,
size_t offset)
inline bool has_infix(std::string_view s, std::string_view infix, size_t offset)
{
return s.compare(offset, infix.size(), infix)==0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/util/prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Author: Daniel Kroening, kroening@kroening.com
#ifndef CPROVER_UTIL_PREFIX_H
#define CPROVER_UTIL_PREFIX_H

#include <string>
#include <string_view>

// C++20 will have std::string::starts_with
// C++20 will have std::string_view::starts_with

inline bool has_prefix(const std::string &s, const std::string &prefix)
inline bool has_prefix(std::string_view s, std::string_view prefix)
{
return s.compare(0, prefix.size(), prefix)==0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/util/suffix.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Author: Daniel Kroening, kroening@kroening.com

#include <string>

// C++20 will have std::string::ends_with
// C++20 will have std::string_view::ends_with

inline bool has_suffix(const std::string &s, const std::string &suffix)
inline bool has_suffix(std::string_view s, std::string_view suffix)
{
if(suffix.size()>s.size())
return false;
Expand Down
Loading