From ee82a5728a3dacbb048e36206ae56f40116fe45f Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 16 Oct 2023 11:31:45 -0700 Subject: [PATCH] [dataset] highlight `SetTlv()` specializations in the docs (#9534) This commit updates the `Dataset::SetTlv()` documentation to mention its specifications for `uint` types (which use big-endian encoding). It also adds `static_assert` checks to ensure that the general template implementation is not used with `uint16/32/64` types. --- src/core/meshcop/dataset.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/meshcop/dataset.hpp b/src/core/meshcop/dataset.hpp index 50ecb2c62..cffa4bcff 100644 --- a/src/core/meshcop/dataset.hpp +++ b/src/core/meshcop/dataset.hpp @@ -770,6 +770,9 @@ public: * * @tparam ValueType The type of TLV's Value. * + * Specializations of this template method are provided for `uint16_t` and `uint32_t` types which ensure big-endian + * encoding is used. + * * @param[in] aType The TLV Type. * @param[in] aValue The TLV Value (of type `ValueType`). * @@ -780,6 +783,9 @@ public: template Error SetTlv(Tlv::Type aType, const ValueType &aValue) { static_assert(!TypeTraits::IsPointer::kValue, "ValueType must not be a pointer"); + static_assert(!TypeTraits::IsSame::kValue, "Specialization must be used for uint16_t"); + static_assert(!TypeTraits::IsSame::kValue, "Specialization must be used for uint32_t"); + static_assert(!TypeTraits::IsSame::kValue, "Specialization must be used for uint64_t"); return SetTlv(aType, &aValue, sizeof(ValueType)); }