You can get rid of is_same
and query_result_t
, since contains
returns an MPL Integral Constant:
typedef boost::variant<int, double, std::string> my_variant;
template<typename T>
void Func()
{
static_assert(boost::mpl::contains<my_variant::types, T>::type::value, "T isn't a valid my_variant type.");
// ...
}
I believe that's as concise as it gets - you need some predicate to query the type sequence, and boost::mpl::contains
is the correct one for that.