diff options
author | nat-goodspeed <nat@lindenlab.com> | 2024-09-23 18:23:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-23 18:23:56 -0400 |
commit | 9036e4582cec1893016bd692293ec1c0135f7112 (patch) | |
tree | f1dabff03453d87a78257d872acddb8f86f4da9c /indra/llcommon/always_return.h | |
parent | 9289b96de48e0a3f57819ca173c5d5d51ad25c56 (diff) | |
parent | 74badfcfb07733214cbe5aa5ae02bd413f8465a2 (diff) |
Merge pull request #2652 from secondlife/lua-merge-dev2
Merge develop into release/luau-scripting
Diffstat (limited to 'indra/llcommon/always_return.h')
-rw-r--r-- | indra/llcommon/always_return.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/indra/llcommon/always_return.h b/indra/llcommon/always_return.h index a206471da5..a56a8b443e 100644 --- a/indra/llcommon/always_return.h +++ b/indra/llcommon/always_return.h @@ -14,6 +14,7 @@ #define LL_ALWAYS_RETURN_H #include <type_traits> // std::enable_if, std::is_convertible +#include <utility> // std::forward namespace LL { @@ -79,6 +80,22 @@ namespace LL DESIRED mDefault; }; + // specialize for AlwaysReturn<void> + template <> + struct AlwaysReturn<void> + { + public: + AlwaysReturn() {} + + // callable returns a type not convertible to DESIRED, return default + template <typename CALLABLE, typename... ARGS> + void operator()(CALLABLE&& callable, ARGS&&... args) + { + // discard whatever callable(args) returns + std::forward<CALLABLE>(callable)(std::forward<ARGS>(args)...); + } + }; + /** * always_return<T>(some_function, some_args...) calls * some_function(some_args...). It is guaranteed to return a value of type |