1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi"). 10 #include <initializer_list> 12 #include <string_view> 17 basic_string_view, begin, binary_search, bitset, end, find, initializer_list
20 template<
class Char >
21 inline auto is_in(
const basic_string_view<Char>& sv,
const Char ch ) noexcept
23 {
return 0 <= static_cast<Size>( sv.find( ch ) ); }
25 template<
class Item,
class Value >
26 inline auto is_in(
const initializer_list<Item>& items,
const Value& v ) noexcept
29 for(
auto& item : items )
31 if( item == v ) {
return true; }
37 inline auto is_in(
const bitset<n>& bits,
const int i ) noexcept
44 template<
class It,
class Arg >
45 auto is_in_span(
const It begin,
const It end,
const Arg& v )
47 {
return find( begin, end, v ) != end; }
49 template<
class Key, Size n,
class Arg >
52 {
return is_in_range( begin( a ), end( a ), v ); }
54 template<
class It,
class Arg >
57 {
return binary_search( begin, end, v ); }
59 template<
class Key, Size n,
class Arg >
62 {
return is_in_sorted_range( begin( a ), end( a ), v ); }
A drop-in replacement for bool without implicit conversion from/to types other than bool.
auto is_in(const basic_string_view< Char > &sv, const Char ch) noexcept -> Truth
Truth is a drop-in replacement for bool without implicit conversion from/to types other than bool.
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
Simple type builders Type_, P_, R_, Raw_array_ and Raw_array_of_.
auto is_in_sorted(Raw_array_of_< n, const Key > &a, const Arg &v) -> Truth
auto is_in_span(const It begin, const It end, const Arg &v) -> Truth
Item[n] Raw_array_of_
Creates a raw array type of a specified size.
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...
Signed Size and Index, plus unsigned equivalents Unsigned_size and Unsigned_index.
auto is_in_sorted_span(const It begin, const It end, const Arg &v) -> Truth