From b40dfec619e0e917e21ccf2b56c0c75f43427d99 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 18 Jan 2022 10:59:44 -0600 Subject: [PATCH] util: variant: add static assert The two variant utilities both have an 'Unused' template parameter pack which is expected to be empty. Add static assert to confirm the parameter pack is indeed always empty. (Generally the non-empty parameter pack should match with a specialization.) Signed-off-by: Patrick Williams Change-Id: Iae4523142df563d208e20ab81dd47266b3f7dd27 --- include/sdbusplus/utility/dedup_variant.hpp | 1 + include/sdbusplus/utility/merge_variants.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/sdbusplus/utility/dedup_variant.hpp b/include/sdbusplus/utility/dedup_variant.hpp index bfffd20f..786f7ef4 100644 --- a/include/sdbusplus/utility/dedup_variant.hpp +++ b/include/sdbusplus/utility/dedup_variant.hpp @@ -25,6 +25,7 @@ template struct dedup_variant { using type = T; + static_assert(sizeof...(Unused) == 0); }; /** Find the deduplicated variant type. diff --git a/include/sdbusplus/utility/merge_variants.hpp b/include/sdbusplus/utility/merge_variants.hpp index 89c55711..70796821 100644 --- a/include/sdbusplus/utility/merge_variants.hpp +++ b/include/sdbusplus/utility/merge_variants.hpp @@ -26,6 +26,7 @@ template struct merge_variants { using type = T; + static_assert(sizeof...(Unused) == 0); }; /** Compute the merged variant type.