Boost logo

Boost Users :

Subject: Re: [Boost-users] Error while typecasting the boost::variant ( need help)
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-04-13 15:14:36


On Fri, Apr 13, 2012 at 12:01 PM, Baba Prasad <gbabu_at_[hidden]>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



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