diff options
Diffstat (limited to 'include/input/PrintTools.h')
-rw-r--r-- | include/input/PrintTools.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/input/PrintTools.h b/include/input/PrintTools.h index 0a75278494..55f730b287 100644 --- a/include/input/PrintTools.h +++ b/include/input/PrintTools.h @@ -17,6 +17,7 @@ #pragma once #include <map> +#include <optional> #include <set> #include <string> @@ -28,6 +29,15 @@ std::string constToString(const T& v) { } /** + * Convert an optional type to string. + */ +template <typename T> +std::string toString(const std::optional<T>& optional, + std::string (*toString)(const T&) = constToString) { + return optional ? toString(*optional) : "<not set>"; +} + +/** * Convert a set of integral types to string. */ template <typename T> |