From 4e7febfa2ca9a3c95470b8d78eade9d2fdfda5e3 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Sun, 2 Jun 2019 21:35:27 +0200 Subject: [PATCH] get_if may not be called if there is more than one match --- include/boost/histogram/detail/variant.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/histogram/detail/variant.hpp b/include/boost/histogram/detail/variant.hpp index dba9f219..36eef927 100644 --- a/include/boost/histogram/detail/variant.hpp +++ b/include/boost/histogram/detail/variant.hpp @@ -130,12 +130,14 @@ public: template T* get_if() noexcept { + static_assert(mp11::mp_count::value <= 1, "no unique match for T"); constexpr auto i = mp11::mp_find{}; return i == index_ ? &ref() : nullptr; } template const T* get_if() const noexcept { + static_assert(mp11::mp_count::value <= 1, "no unique match for T"); constexpr auto i = mp11::mp_find{}; return i == index_ ? &ref() : nullptr; }