From 88850fadb5d5c3bce5ca2959b81cca1cd067c8ca Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 26 Jun 2021 17:36:36 +0100 Subject: General purpose optional stream<< --- test/helpers.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/helpers.h b/test/helpers.h index 107eda5..59ae18d 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include inline constexpr std::byte operator""_b(const unsigned long long hex) { @@ -24,6 +26,18 @@ namespace std { { return to_integer(b) != i; } + + template + ostream & + operator<<(ostream & s, const std::optional & o) + { + if (o) { + return s << *o; + } + else { + return s << "-"; + } + } } inline struct tm -- cgit v1.2.3