diff --git a/gucc/include/gucc/string_utils.hpp b/gucc/include/gucc/string_utils.hpp index d9e8927..c678586 100644 --- a/gucc/include/gucc/string_utils.hpp +++ b/gucc/include/gucc/string_utils.hpp @@ -75,18 +75,14 @@ constexpr auto make_split_view(std::string_view str, char delim = '\n') noexcept | ranges::views::filter(second); } -template > +template concept string_findable = requires(T value) { - // check that type of T::npos is T::size_type - { npos_type{} } -> std::same_as; - // check that type of T::find is T::size_type - { value.find(std::string_view{""}) } -> std::same_as; + // check that type of T::contains is bool + { value.contains(std::string_view{""}) } -> std::same_as; }; - // simple helper function to check if string contains a string constexpr auto contains(string_findable auto const& str, std::string_view needle) noexcept -> bool { - using str_type = std::remove_reference_t; - return str.find(needle) != str_type::npos; + return str.contains(needle); } template