From 754566ec15c46415be3b5c9cb1f39c5604166b16 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Mon, 7 Feb 2022 13:39:53 +0300 Subject: [PATCH] Add stream output operator for enums --- libs/util/include/psemek/util/enum.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/util/include/psemek/util/enum.hpp b/libs/util/include/psemek/util/enum.hpp index 7bf272b2..c2e20bad 100644 --- a/libs/util/include/psemek/util/enum.hpp +++ b/libs/util/include/psemek/util/enum.hpp @@ -90,6 +90,8 @@ namespace psemek::util }; \ auto it = map.find(str); if (it == map.end()) return std::nullopt; return it->second; \ } \ + template \ + inline ::std::basic_ostream & operator << (::std::basic_ostream & os, name value) { return os << to_string(value); } \ inline ::psemek::util::enum_range BOOST_PP_CAT(name, _values) () { return {0, BOOST_PP_SEQ_SIZE(values)}; }