diff options
author | asynts <asynts@gmail.com> | 2020-08-25 15:18:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-26 21:07:53 +0200 |
commit | 18b3de755556bfcfa0fd5d00e54b9f14ea36b6f9 (patch) | |
tree | 6fff31f0d8eb57cd954f84860b0e83ee9112a31d /AK | |
parent | e3bfe0b5095e9a0bdeb73d8f72bab3138f4494bf (diff) | |
download | serenity-18b3de755556bfcfa0fd5d00e54b9f14ea36b6f9.zip |
AK: Add stream operators for Optional.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Stream.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/AK/Stream.h b/AK/Stream.h index c1d0e00ec7..10807407d8 100644 --- a/AK/Stream.h +++ b/AK/Stream.h @@ -31,6 +31,7 @@ #include <AK/Endian.h> #include <AK/Forward.h> #include <AK/MemMem.h> +#include <AK/Optional.h> #include <AK/Span.h> #include <AK/StdLibExtras.h> #include <AK/Vector.h> @@ -104,6 +105,15 @@ InputStream& operator<<(InputStream& stream, BigEndian<T> value) return stream; } +template<typename T> +InputStream& operator>>(InputStream& stream, Optional<T>& value) +{ + T temporary; + stream >> temporary; + value = temporary; + return stream; +} + #if defined(__cpp_concepts) && !defined(__COVERITY__) template<Concepts::Integral Integral> #else |