Proposal: meta_any::try_cast
to one of a closed set of types
#1172
Labels
enhancement
accepted requests, sooner or later I'll do it
Suppose I have an instance of
meta_any
that I know may hold one of a closed set of different types.With the current interface of
meta_any
, I cantry_cast
to each of the types, one after the other, and check the returned pointer until I find the correct type.If there was e.g. an overload for
try_cast
that took a parameter pack of those types and returned anstd::variant
, containing the result of the first succesful cast, I could thenstd::visit
thatstd::variant
:This overload could be added to
meta_any
, but some thought would need to be put into communicating an unsuccesful try.The text was updated successfully, but these errors were encountered: