I'm trying to construct a std::variant out of a boost::variant. In practice, I'm trying to define a function with the following signature:
template <typename... Types>
std::variant<Types...>
boostvar2stdvar(boost::variant<Types...> input);
I've seen the answer to this question, but in that case it's converting a tuple to a std::variant, not a boost::variant. I need my function to take a boost::variant directly. Is there an easy way to do that?
As others have pointed out, you can visit all elements types and return the desired variant from there:
When used like this
Then type of x matches the expected:
Live
See it Live On Coliru