10#include <unordered_set>
18template <
typename T,
typename U>
19bool CanTypeFitValue(
const U value)
21 const intmax_t botT = intmax_t(std::numeric_limits<T>::min());
22 const intmax_t botU = intmax_t(std::numeric_limits<U>::min());
23 const uintmax_t topT = uintmax_t(std::numeric_limits<T>::max());
24 const uintmax_t topU = uintmax_t(std::numeric_limits<U>::max());
25 return !((botT > botU && value < static_cast<U>(botT)) || (topT < topU && value >
static_cast<U
>(topT)));
28template <
typename CharT1,
size_t size = sizeof(CharT1)>
31template <
typename CharT1>
32struct CharSet<CharT1, 1> {
33 using UCharT1 =
typename std::make_unsigned<CharT1>::type;
35 std::array<bool, std::numeric_limits<UCharT1>::max() + 1> m_val;
40 void insert(CharT1 ch)
42 m_val[UCharT1(ch)] =
true;
45 template <
typename CharT2>
46 bool find(CharT2 ch)
const
48 if (!CanTypeFitValue<CharT1>(ch))
return false;
50 return m_val[UCharT1(ch)];
54template <
typename CharT1,
size_t size>
56 std::unordered_set<CharT1> m_val;
61 void insert(CharT1 ch)
66 template <
typename CharT2>
67 bool find(CharT2 ch)
const
69 if (!CanTypeFitValue<CharT1>(ch))
return false;
71 return m_val.find(CharT1(ch)) != m_val.end();