diff options
author | rtk0c <[email protected]> | 2021-04-16 16:49:28 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-04-16 16:49:28 -0700 |
commit | 4e5730e1fcef150ce2f13f52a278890589ca96ad (patch) | |
tree | 0fe4002349047c7c770754e273d6a1d1ed666cbb /core/src/Utils/Variant.hpp | |
parent | 80d8ae5a6fef6c9a34e81e240539cb655dd99851 (diff) |
More work on workflows
- WorkflowStep -> WorkflowNode
- Added initial kinds of WorkflowNode's
Diffstat (limited to 'core/src/Utils/Variant.hpp')
-rw-r--r-- | core/src/Utils/Variant.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/src/Utils/Variant.hpp b/core/src/Utils/Variant.hpp new file mode 100644 index 0000000..7fdb2dc --- /dev/null +++ b/core/src/Utils/Variant.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include <utility> +#include <variant> + +template <class... Ts> +struct Overloaded : Ts... { using Ts::operator()...; }; +template <class... Ts> +Overloaded(Ts...) -> Overloaded<Ts...>; + +template <class... Args> +struct VariantCastProxy { + std::variant<Args...> v; + + template <class... ToArgs> + operator std::variant<ToArgs...>() const { + return std::visit( + [](auto&& arg) -> std::variant<ToArgs...> { return arg; }, + v); + } +}; + +/// Use snake_case naming to align with `static_cast`, `dynamic_cast`, etc.. +template <class... Args> +auto variant_cast(std::variant<Args...> v) -> VariantCastProxy<Args...> { + return { std::move(v) }; +} |