Skip to content

Commit

Permalink
std::equal is not necessarily constexpr in C++17 (#512)
Browse files Browse the repository at this point in the history
* std::equal is not necessarily constexpr in C++17, so PR #474 broke ada technically.

* clang-format
  • Loading branch information
lemire authored Sep 19, 2023
1 parent f4dc343 commit 661717e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions include/ada/checkers-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ inline constexpr bool is_normalized_windows_drive_letter(
return input.size() >= 2 && (is_alpha(input[0]) && (input[1] == ':'));
}

ada_really_inline constexpr bool begins_with(std::string_view view,
std::string_view prefix) {
ada_really_inline bool begins_with(std::string_view view,
std::string_view prefix) {
// in C++20, you have view.begins_with(prefix)
// std::equal is constexpr in C++20
return view.size() >= prefix.size() &&
std::equal(prefix.begin(), prefix.end(), view.begin());
}
Expand Down
6 changes: 3 additions & 3 deletions include/ada/checkers.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ inline constexpr bool is_normalized_windows_drive_letter(
std::string_view input) noexcept;

/**
* @warning Will be removed when Ada supports C++20.
* @warning Will be removed when Ada requires C++20.
*/
ada_really_inline constexpr bool begins_with(std::string_view view,
std::string_view prefix);
ada_really_inline bool begins_with(std::string_view view,
std::string_view prefix);

/**
* Returns true if an input is an ipv4 address.
Expand Down

0 comments on commit 661717e

Please sign in to comment.