mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibRegex: Allow RegexOptions to be declared at compile time
This commit is contained in:
parent
f1809db994
commit
4a72b2c879
1 changed files with 9 additions and 9 deletions
|
@ -74,13 +74,13 @@ public:
|
|||
|
||||
RegexOptions() = default;
|
||||
|
||||
RegexOptions(T flags)
|
||||
constexpr RegexOptions(T flags)
|
||||
: m_flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
template<class U>
|
||||
RegexOptions(RegexOptions<U> other)
|
||||
constexpr RegexOptions(RegexOptions<U> other)
|
||||
: m_flags((T) static_cast<FlagsUnderlyingType>(other.value()))
|
||||
{
|
||||
}
|
||||
|
@ -88,16 +88,16 @@ public:
|
|||
operator bool() const { return !!*this; }
|
||||
bool operator!() const { return (FlagsUnderlyingType)m_flags == 0; }
|
||||
|
||||
RegexOptions<T> operator|(T flag) const { return RegexOptions<T> { (T)((FlagsUnderlyingType)m_flags | (FlagsUnderlyingType)flag) }; }
|
||||
RegexOptions<T> operator&(T flag) const { return RegexOptions<T> { (T)((FlagsUnderlyingType)m_flags & (FlagsUnderlyingType)flag) }; }
|
||||
constexpr RegexOptions<T> operator|(T flag) const { return RegexOptions<T> { (T)((FlagsUnderlyingType)m_flags | (FlagsUnderlyingType)flag) }; }
|
||||
constexpr RegexOptions<T> operator&(T flag) const { return RegexOptions<T> { (T)((FlagsUnderlyingType)m_flags & (FlagsUnderlyingType)flag) }; }
|
||||
|
||||
RegexOptions<T>& operator|=(T flag)
|
||||
constexpr RegexOptions<T>& operator|=(T flag)
|
||||
{
|
||||
m_flags = (T)((FlagsUnderlyingType)m_flags | (FlagsUnderlyingType)flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RegexOptions<T>& operator&=(T flag)
|
||||
constexpr RegexOptions<T>& operator&=(T flag)
|
||||
{
|
||||
m_flags = (T)((FlagsUnderlyingType)m_flags & (FlagsUnderlyingType)flag);
|
||||
return *this;
|
||||
|
@ -114,19 +114,19 @@ private:
|
|||
};
|
||||
|
||||
template<class T>
|
||||
inline RegexOptions<T> operator|(T lhs, T rhs)
|
||||
constexpr RegexOptions<T> operator|(T lhs, T rhs)
|
||||
{
|
||||
return RegexOptions<T> { lhs } |= rhs;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline RegexOptions<T> operator&(T lhs, T rhs)
|
||||
constexpr RegexOptions<T> operator&(T lhs, T rhs)
|
||||
{
|
||||
return RegexOptions<T> { lhs } &= rhs;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T operator~(T flag)
|
||||
constexpr T operator~(T flag)
|
||||
{
|
||||
return (T) ~((FlagsUnderlyingType)flag);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue