sdbus++: events: simplify constructor

Consolidate consteval_string usage to simplify the generated code.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I6340eb369c117bb580a128e5338113a4b38a0f80
diff --git a/include/sdbusplus/exception.hpp b/include/sdbusplus/exception.hpp
index a9ddab0..3b01466 100644
--- a/include/sdbusplus/exception.hpp
+++ b/include/sdbusplus/exception.hpp
@@ -3,6 +3,7 @@
 #include <systemd/sd-bus.h>
 
 #include <sdbusplus/sdbus.hpp>
+#include <sdbusplus/utility/consteval_string.hpp>
 
 #include <exception>
 #include <string>
@@ -65,6 +66,9 @@
     {
         return Event::errErrno;
     }
+
+    template <utility::details::consteval_string_holder V>
+    using metadata_t = utility::consteval_string<V>;
 };
 
 /** base exception class for all errors generated by sdbusplus itself. */
diff --git a/tools/sdbusplus/templates/event.hpp.mako b/tools/sdbusplus/templates/event.hpp.mako
index 674c9dc..24bc819 100644
--- a/tools/sdbusplus/templates/event.hpp.mako
+++ b/tools/sdbusplus/templates/event.hpp.mako
@@ -1,20 +1,11 @@
 struct ${event.CamelCase} final :
     public sdbusplus::exception::generated_event<${event.CamelCase}>
 {
-    static constexpr auto errName =
-        "${events.name}.${event.name}";
-    static constexpr auto errDesc =
-        "${event.description}";
-    static constexpr auto errWhat =
-        "${events.name}.${event.name}: ${event.description}";
-
-    static constexpr auto errErrno = ${event.errno};
-
 %if len(event.metadata) > 0:
     ${event.CamelCase}() = delete;
     ${event.CamelCase}(
         ${", ".join([
-            f"utility::consteval_string<\"{m.SNAKE_CASE}\">, {m.cppTypeParam(events.name)} {m.camelCase}_"
+            f"metadata_t<\"{m.SNAKE_CASE}\">, {m.cppTypeParam(events.name)} {m.camelCase}_"
             for m in event.metadata ])}) :
         ${", ".join([
             f"{m.camelCase}({m.camelCase}_)" for m in event.metadata ])}
@@ -23,5 +14,14 @@
 %for m in event.metadata:
     ${m.cppTypeParam(events.name)} ${m.camelCase};
 %endfor
+
 %endif
+    static constexpr auto errName =
+        "${events.name}.${event.name}";
+    static constexpr auto errDesc =
+        "${event.description}";
+    static constexpr auto errWhat =
+        "${events.name}.${event.name}: ${event.description}";
+
+    static constexpr auto errErrno = ${event.errno};
 };
diff --git a/tools/sdbusplus/templates/events.hpp.mako b/tools/sdbusplus/templates/events.hpp.mako
index c2e945c..6dd9c86 100644
--- a/tools/sdbusplus/templates/events.hpp.mako
+++ b/tools/sdbusplus/templates/events.hpp.mako
@@ -3,7 +3,6 @@
  */
 #pragma once
 #include <sdbusplus/exception.hpp>
-#include <sdbusplus/utility/consteval_string.hpp>
 
 #include <cerrno>