id summary reporter owner description type status milestone component version severity resolution keywords cc 9479 polymorphic_get<> for variant Antony Polukhin Antony Polukhin "The original idea was described [http://coliru.stacked-crooked.com/a/3e920faa604fa534 here]: {{{ #include #include #include //------------------------------------------------------------------------------ struct unused { template unused(T&) {} }; template struct Getter { typedef T* result_type; T* operator()(T& v) const { return &v; } T* operator()(unused) const { return nullptr; } }; template U* poly_get(T* v) { return boost::apply_visitor(Getter(), *v); } //------------------------------------------------------------------------------ struct O{ }; struct A:O{ }; struct B:O{ }; int main(int argc, char** argv) { boost::variant v; std::cout << ""boost::get-------------------------------\n""; std::cout << boost::get(&v) << std::endl; std::cout << boost::get(&v) << std::endl; std::cout << boost::get(&v) << std::endl; std::cout << ""poly_get---------------------------------\n""; std::cout << poly_get(&v) << std::endl; std::cout << poly_get(&v) << std::endl; std::cout << poly_get(&v) << std::endl; } }}}" Feature Requests closed Boost 1.56.0 variant Boost 1.54.0 Problem fixed