From 447d016ae71a50928ee72932bafb423937e8a3f4 Mon Sep 17 00:00:00 2001 From: Gareth Potter Date: Tue, 4 Aug 2026 15:23:28 +0100 Subject: [PATCH 1/3] use C++ 20 constraint rather than static assertion to ensure correct number of named parameters --- include/thingset++/ThingSetFunction.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/thingset++/ThingSetFunction.hpp b/include/thingset++/ThingSetFunction.hpp index b635b71..4b267de 100644 --- a/include/thingset++/ThingSetFunction.hpp +++ b/include/thingset++/ThingSetFunction.hpp @@ -66,11 +66,9 @@ struct ThingSetParameterNames /// @tparam Result The return type of the function. /// @tparam ...Args The argument types of the function, if any. template + requires (ParamNames::count == 0 || ParamNames::count == sizeof...(Args)) class ThingSetFunction : public IdentifiableThingSetParentNode, public ThingSetInvocable { - static_assert(ParamNames::count == 0 || ParamNames::count == sizeof...(Args), - "ThingSetParameterNames must either be empty or name every argument"); - private: template class ThingSetFunctionParameter : public IdentifiableThingSetNode From 4a1dfce8418a4f63d4f5d660f5787abe7772bf8a Mon Sep 17 00:00:00 2001 From: Gareth Potter Date: Tue, 4 Aug 2026 15:38:16 +0100 Subject: [PATCH 2/3] use template specialisation for param name defaulting --- include/thingset++/ThingSetFunction.hpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/include/thingset++/ThingSetFunction.hpp b/include/thingset++/ThingSetFunction.hpp index 4b267de..a990d9d 100644 --- a/include/thingset++/ThingSetFunction.hpp +++ b/include/thingset++/ThingSetFunction.hpp @@ -49,13 +49,27 @@ struct ThingSetParameterNames { static constexpr size_t count = sizeof...(Names); - template + template static constexpr auto get() { return std::get(std::tuple{ Names... }); } }; +/// @brief Empty specialisation of ThingSetParameterNames for the +/// default case which auto-generates parameter names. +template <> +struct ThingSetParameterNames<> +{ + static constexpr size_t count = 0; + + template + static constexpr auto get() + { + return Name + ThingSetType>::name + "_" + to_string_t<1 + Index>(); + } +}; + /// @brief Represents an executable function. /// @tparam Id The unique integer ID of the ThingSet node. /// @tparam ParentId The integer ID of the parent node. @@ -106,12 +120,7 @@ class ThingSetFunction : public IdentifiableThingSetParentNode(); - } - else { - return Name + ThingSetType>::name + "_" + to_string_t<1 + Index>(); - } + return ParamNames::template get(); } typedef ThingSetFunctionParameter type; From 62122db6bc5c532656c32e6f8c628b92c2ea82eb Mon Sep 17 00:00:00 2001 From: Gareth Potter Date: Tue, 4 Aug 2026 15:52:47 +0100 Subject: [PATCH 3/3] update README --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fe15e1..296c465 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,12 @@ ThingSetUserFunction<0x410, 0x0, int, std::string &> xStringLength(getStringLeng ``` Note that, by default, parameters' IDs will be generated by incrementing the function -ID. It is possible to override this. +ID. It is possible to override this. Parameter names will be generated from a combination of the +function name, parameter type and parameter index. This too can be overridden: + +```c++ +ThingSetNamedUserFunction<0x470, 0x0, "xNamed", ThingSetParameterNames<"uAlpha", "uBeta">, int, uint16_t, float> xNamed([](uint16_t, float) { return 0; }); +``` Once you have declared your properties and functions, instantiate a server with an appropriate transport to expose them to clients.