diff --git a/src/lib/access-casted.hpp b/src/lib/access-casted.hpp index eff197e4b..b4ec5462f 100644 --- a/src/lib/access-casted.hpp +++ b/src/lib/access-casted.hpp @@ -162,8 +162,21 @@ namespace util { return AccessCasted::access (*elem); } + + + /** catch-all to signal failure of conversion */ + static TAR + access (...) + { + // NOTE: if you see this assertion failure, none of the above predicates were true. + // Chances are that you requested a conversion that is logically impossible or dangerous, + // like e.g. taking a reference from an anonymous value parameter + static_assert (!sizeof(TAR), "AccessCasted: No valid conversion or cast supported for these types."); + throw error::Invalid("impossible or unsafe type conversion requested"); + } }; + } // namespace util #endif