From 3f6d7351816b0e089495b2f15dc1c956f3151f5a Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 4 Feb 2024 14:08:32 +0000 Subject: Reworked ReturnByValue, warn_or_error, expect_date_[identifier_or_]string --- src/openvic-simulation/utility/Getters.hpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/openvic-simulation/utility/Getters.hpp') 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 + 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 || std::floating_point || std::is_enum_v || std::derived_from + std::integral || std::floating_point || std::is_enum_v || ReturnByValue ) { /* Return value */ return T { property }; -- cgit v1.2.3-56-ga3b1