summaryrefslogtreecommitdiff
path: root/lib/stream_support.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-10-22 17:57:47 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-10-22 17:57:47 +0100
commit38d7045685d4904d013ea4990a3aa7f5e78309cf (patch)
tree60915147de5e37dc4a3fab39408b6abbfc49ce09 /lib/stream_support.hpp
parentAdd free extend builder with placeholder network support (diff)
downloadilt-38d7045685d4904d013ea4990a3aa7f5e78309cf.tar.bz2
ilt-38d7045685d4904d013ea4990a3aa7f5e78309cf.tar.xz
ilt-38d7045685d4904d013ea4990a3aa7f5e78309cf.zip
Add magic support to printing/parsing/validating enumerations
Diffstat (limited to 'lib/stream_support.hpp')
-rw-r--r--lib/stream_support.hpp11
1 files changed, 11 insertions, 0 deletions
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 <glm/glm.hpp>
#include <iostream>
#include <maths.h>
@@ -51,6 +52,16 @@ namespace std {
{
return s << arc.first << " ↺ " << arc.second;
}
+
+ template<typename E>
+ concept IsEnum = std::is_enum_v<E>;
+
+ template<IsEnum E>
+ inline std::ostream &
+ operator<<(std::ostream & s, const E & e)
+ {
+ return s << EnumTypeDetails<E>::typeName << "::" << EnumDetails<E>::to_string(e).value();
+ }
}
template<typename T>