Unsafe, `noexcept` and no-overhead way of accessing `std::variant`
问题 std::variant provides the following access functions: std::get_if: take pointer to variant , return pointer to alternative. template <std::size_t I, typename... Ts> auto* std::get_if(std::variant<Ts...>* pv) noexcept; If pv is not a null pointer and pv->index() == I , returns a pointer to the value stored in the variant pointed to by pv . Otherwise, returns a null pointer value. This means that get_if 's implementation roughly looks like this: template <std::size_t I, typename... Ts> auto*