Error while typecasting the boost::variant ( need help)

Dear Friend my program is typedef std::vector<int> vec_name; struct network { boost::variant<vec_name> net_id; }; typedef std::vector<network>network_list; // create the instance for vector network_list net_list; for(int i=0; i<net_list.size(); ++i) { unsigned char* query_str = net_list[0].net_id; } ERROR is error: cannot convert boost::variant<odtone::mih::null, std::vector<std::basic_string<char> > > to unsigned char* in assignment Best Regards BaBu -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.

On Fri, Apr 13, 2012 at 12:01 PM, Baba Prasad <gbabu@ece.iisc.ernet.in>wrote:
Dear Friend
my program is
typedef std::vector<int> vec_name;
struct network { boost::variant<vec_name> net_id; };
typedef std::vector<network>network_list;
// create the instance for vector
network_list net_list;
for(int i=0; i<net_list.size(); ++i) { unsigned char* query_str = net_list[0].net_id; }
ERROR is error: cannot convert ‘boost::variant<odtone::mih::null, std::vector<std::basic_string<char> > >’ to ‘unsigned char*’ in assignment
You can use boost::apply_visitor [1], but I have no idea how want to map a std::vector< std::string > or std::vector< int > (your error message is inconsistent with your code, AFAICT) to an unsigned char* (I can only presume that odtone::mih::null -> null pointer). - Jeff [1] http://www.boost.org/doc/libs/1_49_0/doc/html/boost/apply_visitor.html
participants (2)
-
Baba Prasad
-
Jeffrey Lee Hellrung, Jr.