mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +00:00
AK: Add stream operators for Optional.
This commit is contained in:
parent
e3bfe0b509
commit
18b3de7555
Notes:
sideshowbarker
2024-07-19 03:07:16 +09:00
Author: https://github.com/asynts
Commit: 18b3de7555
Pull-request: https://github.com/SerenityOS/serenity/pull/3309
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/stelar7
1 changed files with 10 additions and 0 deletions
10
AK/Stream.h
10
AK/Stream.h
|
@ -31,6 +31,7 @@
|
||||||
#include <AK/Endian.h>
|
#include <AK/Endian.h>
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/MemMem.h>
|
#include <AK/MemMem.h>
|
||||||
|
#include <AK/Optional.h>
|
||||||
#include <AK/Span.h>
|
#include <AK/Span.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
@ -104,6 +105,15 @@ InputStream& operator<<(InputStream& stream, BigEndian<T> value)
|
||||||
return stream;
|
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__)
|
#if defined(__cpp_concepts) && !defined(__COVERITY__)
|
||||||
template<Concepts::Integral Integral>
|
template<Concepts::Integral Integral>
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue