Boost logo

Boost Users :

From: Nindi Singh (nindi73_at_[hidden])
Date: 2006-07-01 13:17:43


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;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net