diff options
author | Hop311 <Hop3114@gmail.com> | 2023-11-07 22:38:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 22:38:07 +0100 |
commit | ae2742113ec7283a2a5afa62f8bfd98a865c4208 (patch) | |
tree | 601591215af0c6724766019ebb577141ea5807c5 /src/openvic-simulation/dataloader/NodeTools.hpp | |
parent | 1603fbafb1c03830f38fefd87d8bd0d7d3f135a2 (diff) | |
parent | d30421fa7d7f6ad87d3f90cc0ab491742f0d2548 (diff) |
Merge pull request #64 from OpenVicProject/modifier-instance
ModifierEffects stored as instances
Diffstat (limited to 'src/openvic-simulation/dataloader/NodeTools.hpp')
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index 798976f..a23fb4f 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -4,6 +4,7 @@ #include <cstdint> #include <functional> #include <map> +#include <optional> #include <set> #include <type_traits> @@ -66,7 +67,7 @@ namespace OpenVic { } node_callback_t expect_identifier(callback_t<std::string_view> callback); - node_callback_t expect_string(callback_t<std::string_view> callback, bool allow_empty = true); + node_callback_t expect_string(callback_t<std::string_view> callback, bool allow_empty = false); node_callback_t expect_identifier_or_string(callback_t<std::string_view> callback, bool allow_empty = false); node_callback_t expect_bool(callback_t<bool> callback); @@ -261,15 +262,8 @@ namespace OpenVic { }; } - template<std::integral T> - callback_t<T> assign_variable_callback_cast(auto& var) { - return [&var](T val) -> bool { - var = val; - return true; - }; - } - - template<std::signed_integral T> + template<typename T> + requires std::is_integral_v<T> || std::is_enum_v<T> callback_t<T> assign_variable_callback_cast(auto& var) { return [&var](T val) -> bool { var = val; @@ -317,5 +311,13 @@ namespace OpenVic { return true; }; } + + template<typename T> + Callback<T const&> auto assign_variable_callback_pointer(std::optional<T const*>& var) { + return [&var](T const& val) -> bool { + var = &val; + return true; + }; + } } } |