here I have some class to test the boost::any_cast,usually I use intel compiler 10.0,but I got a message the application must be close.
but the ms vc 8.0 compiler works well.
My operator is windows xp,and I use vs2005 with inter compiler 10.0
here is my code:
-----------------------------------------------------------------------------------------------------------------------------------------
class CA{public: void tellme() { cout<<"I am ca"<tellme(); } else if (CB* p = boost::any_cast<CB>(&ra)) { p->tellme(); } else if (CC* p = boost::any_cast<CC>(&ra)) { p->tellme(); } else if(string* p = boost::any_cast<string>(&ra)) { cout<<*p<boost::any va; va.push_back(CA()); va.push_back(CB()); va.push_back(CC()); va.push_back(string("haha,it a string")); va.push_back(dotellme()); va.push_back(5); dotellme dt; for_each(va.begin(),va.end(),dotellme()); va.clear(); return 0;}
_________________________________________________________________
手机也能上 MSN 聊天了,快来试试吧!
http://mobile.msn.com.cn/