
1 Jul
2006
1 Jul
'06
5:17 p.m.
This has the desired effects BUT ... I am not a software engineer .. so I would like to know is it would the proffessionals would consider ugly code ? #include<string> #include<boost/variant.hpp> typedef boost::variant< bool,std::string> BoostVariant; struct MyVariant:public BoostVariant { template<typename type> MyVariant(const type &theType):BoostVariant(theType){} MyVariant(const char *theCString):BoostVariant(std::string(theCString)){} }; int main () { MyVariant v("A String"); std::string &Sref(boost::get<std::string&>(v)); // NOw this does NOT throw bool &Bref(boost::get<bool&>(v)); // but this does return 0; }