From 5375231ce5e06ea69c71f73e0582383331f714e7 Mon Sep 17 00:00:00 2001 From: Brett Date: Mon, 16 Sep 2024 16:48:05 -0400 Subject: [PATCH] fix missing string def --- CMakeLists.txt | 2 +- include/blt/std/string.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f593022..a5be2b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 0.20.5) +set(BLT_VERSION 0.20.6) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/std/string.h b/include/blt/std/string.h index 15f863e..9dafc52 100644 --- a/include/blt/std/string.h +++ b/include/blt/std/string.h @@ -91,7 +91,16 @@ namespace blt::string #endif } - BLT_CPP20_CONSTEXPR bool ends_with(std::string_view string, std::string_view search); + inline BLT_CPP20_CONSTEXPR bool ends_with(std::string_view string, std::string_view search) + { +#ifdef BLT_USE_CPP20 + return string.ends_with(search); +#else + if (string.empty()) + return false; + return string.substr(string.size() - search.size()) == search; +#endif + } static inline BLT_CPP20_CONSTEXPR bool ends_with(std::string_view string, char search) {