#include #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \ !defined(BOOST_NO_CXX11_SMART_PTR) #include #include #include #include namespace Core { class AutoConverter { std::shared_ptr t_; public: AutoConverter(std::shared_ptr const & t) : t_(t) {} template operator C () { try { boost::any & a = (*t_); return boost::any_cast(a); } catch(boost::bad_any_cast & e) { std::cerr << "Internal conversion bug: " << "Failed to convert data holder to " << typeid(C).name() << "\n" << e.what() << std::endl; C c = C(); return c; } } }; inline AutoConverter Demo() { std::shared_ptr p_result (new boost::any(std::make_tuple(1, 2, 3, 4))); return p_result; } } // namespace Core int main() { std::tuple test = Core::Demo(); return 0; } #else int main() { return 0; } #endif