Skip to content

Commit 60b0772

Browse files
add all_characters_are and all_characters_are_not
1 parent 1ed2dec commit 60b0772

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

string_parse.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,24 @@ namespace mlib
296296
return container<(str.template nth_element<indexes>())...>{};
297297
}(std::make_index_sequence<str.size()>{});
298298
}
299+
300+
template<char c>
301+
constexpr auto all_characters_are() const noexcept
302+
{
303+
return[&]<std::size_t... indexes>(std::index_sequence<indexes...>)
304+
{
305+
return ((c == str.template nth_element<indexes>()) && ...);
306+
}(std::make_index_sequence<str.size()>{});
307+
}
308+
309+
template<char c>
310+
constexpr auto all_characters_are_not() const noexcept
311+
{
312+
return[&]<std::size_t... indexes>(std::index_sequence<indexes...>)
313+
{
314+
return ((c != str.template nth_element<indexes>()) && ...);
315+
}(std::make_index_sequence<str.size()>{});
316+
}
299317

300318
constexpr auto data() const noexcept { return str.data; }
301319
constexpr auto string_view() const noexcept { return std::string_view{ str.data }; }

0 commit comments

Comments
 (0)