diff options
author | Hop311 <Hop3114@gmail.com> | 2024-02-05 20:38:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 20:38:23 +0100 |
commit | 6489da997cddb20667db0455fa4f38319dc7c883 (patch) | |
tree | 4e343f81b13f166ad4a478962348d4734ea7e11b /src/openvic-simulation/utility/Getters.hpp | |
parent | 068c13ede817d17df599ca3481261bf17ed95604 (diff) | |
parent | 87fa1c74281a651b23089079c4c1621d4fb66d73 (diff) |
Merge pull request #145 from OpenVicProject/gui-loading
Added support for loading all gui files
Diffstat (limited to 'src/openvic-simulation/utility/Getters.hpp')
-rw-r--r-- | src/openvic-simulation/utility/Getters.hpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/openvic-simulation/utility/Getters.hpp b/src/openvic-simulation/utility/Getters.hpp index 33aa5a2..fa76e74 100644 --- a/src/openvic-simulation/utility/Getters.hpp +++ b/src/openvic-simulation/utility/Getters.hpp @@ -51,13 +51,15 @@ public: \ ACCESS: namespace OpenVic { - /* Any struct extending ReturnByValueProperty will be returned by value by PROPERTY-generated getter functions, + /* Any struct tagged with ov_return_by_value will be returned by value by PROPERTY-generated getter functions, * instead of by const reference as structs are by default. Use this for small structs which don't contain any - * dynamically allocated memory, e.g. Date and fixed_point_t. */ - struct ReturnByValueProperty { - constexpr bool operator==(ReturnByValueProperty const&) const = default; - constexpr std::strong_ordering operator<=>(ReturnByValueProperty const&) const = default; - }; + * dynamically allocated memory, e.g. dates and colours. The tag must be public, as in the example below: + * + * public: + * using ov_return_by_value = void; + */ + template<typename T> + concept ReturnByValue = requires { typename T::ov_return_by_value; }; /* * Template function used to choose the return type and provide the implementation @@ -72,7 +74,7 @@ namespace OpenVic { /* Return std::string_view looking at std::string */ return std::string_view { property }; } else if constexpr ( - std::integral<T> || std::floating_point<T> || std::is_enum_v<T> || std::derived_from<T, ReturnByValueProperty> + std::integral<T> || std::floating_point<T> || std::is_enum_v<T> || ReturnByValue<T> ) { /* Return value */ return T { property }; |