Skip to content

Commit

Permalink
util: variant: add static assert
Browse files Browse the repository at this point in the history
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 <[email protected]>
Change-Id: Iae4523142df563d208e20ab81dd47266b3f7dd27
  • Loading branch information
williamspatrick committed Jan 18, 2022
1 parent 5770f51 commit b40dfec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sdbusplus/utility/dedup_variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ template <typename T, typename... Unused>
struct dedup_variant
{
using type = T;
static_assert(sizeof...(Unused) == 0);
};

/** Find the deduplicated variant type.
Expand Down
1 change: 1 addition & 0 deletions include/sdbusplus/utility/merge_variants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ template <typename T, typename... Unused>
struct merge_variants
{
using type = T;
static_assert(sizeof...(Unused) == 0);
};

/** Compute the merged variant type.
Expand Down

0 comments on commit b40dfec

Please sign in to comment.