From 38d7045685d4904d013ea4990a3aa7f5e78309cf Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 22 Oct 2022 17:57:47 +0100 Subject: Add magic support to printing/parsing/validating enumerations --- lib/stream_support.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/stream_support.hpp') diff --git a/lib/stream_support.hpp b/lib/stream_support.hpp index 5238234..2ab2f9d 100644 --- a/lib/stream_support.hpp +++ b/lib/stream_support.hpp @@ -1,5 +1,6 @@ #pragma once +#include "enumDetails.hpp" #include #include #include @@ -51,6 +52,16 @@ namespace std { { return s << arc.first << " ↺ " << arc.second; } + + template + concept IsEnum = std::is_enum_v; + + template + inline std::ostream & + operator<<(std::ostream & s, const E & e) + { + return s << EnumTypeDetails::typeName << "::" << EnumDetails::to_string(e).value(); + } } template -- cgit v1.2.3