Boost.TypeErasure でダウンキャスト
Concept に typeid_<> を定義することで any_cast を使用したダウンキャストを行うことが出来ます。
[ソース]
#include <boost/type_erasure/any.hpp> #include <boost/type_erasure/any_cast.hpp> #include <boost/mpl/vector.hpp> #include <iostream> int main(){ namespace te = boost::type_erasure; te::any< boost::mpl::vector< te::typeid_<>, te::copy_constructible<> > > a(10); int n = te::any_cast<int>(a); std::cout << n << std::endl; return 0; }
[出力]
10