1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

AK: Replace some SFINAE with requires clauses, clean up existing ones

Add requires clauses to constraints on InputStream and OutputStream
operator<< / operator>>. Make the constraint on String::number a
requires clause instead of SFINAE. Also, fix some unecessary IsSame in
Trie where specialized traits exist for the given use cases.
This commit is contained in:
Andrew Kaster 2020-12-30 04:59:14 -07:00 committed by Andreas Kling
parent 49a76164c8
commit 7d49ea9836
4 changed files with 40 additions and 29 deletions

View file

@ -147,14 +147,14 @@ InputStream& operator>>(InputStream& stream, Optional<T>& value)
return stream;
}
template<typename Integral, typename EnableIf<IsIntegral<Integral>::value, int>::Type = 0>
InputStream& operator>>(InputStream& stream, Integral& value)
template<typename Integral>
InputStream& operator>>(InputStream& stream, Integral& value) requires IsIntegral<Integral>::value
{
stream.read_or_error({ &value, sizeof(value) });
return stream;
}
template<typename Integral, typename EnableIf<IsIntegral<Integral>::value, int>::Type = 0>
OutputStream& operator<<(OutputStream& stream, Integral value)
template<typename Integral>
OutputStream& operator<<(OutputStream& stream, Integral value) requires IsIntegral<Integral>::value
{
stream.write_or_error({ &value, sizeof(value) });
return stream;
@ -162,14 +162,14 @@ OutputStream& operator<<(OutputStream& stream, Integral value)
#ifndef KERNEL
template<typename FloatingPoint, typename EnableIf<IsFloatingPoint<FloatingPoint>::value, int>::Type = 0>
InputStream& operator>>(InputStream& stream, FloatingPoint& value)
template<typename FloatingPoint>
InputStream& operator>>(InputStream& stream, FloatingPoint& value) requires IsFloatingPoint<FloatingPoint>::value
{
stream.read_or_error({ &value, sizeof(value) });
return stream;
}
template<typename FloatingPoint, typename EnableIf<IsFloatingPoint<FloatingPoint>::value, int>::Type = 0>
OutputStream& operator<<(OutputStream& stream, FloatingPoint value)
template<typename FloatingPoint>
OutputStream& operator<<(OutputStream& stream, FloatingPoint value) requires IsFloatingPoint<FloatingPoint>::value
{
stream.write_or_error({ &value, sizeof(value) });
return stream;
@ -177,15 +177,4 @@ OutputStream& operator<<(OutputStream& stream, FloatingPoint value)
#endif
inline InputStream& operator>>(InputStream& stream, bool& value)
{
stream.read_or_error({ &value, sizeof(value) });
return stream;
}
inline OutputStream& operator<<(OutputStream& stream, bool value)
{
stream.write_or_error({ &value, sizeof(value) });
return stream;
}
}