Boost logo

Boost Users :

From: Digvijoy Chatterjee (digvijoy.c_at_[hidden])
Date: 2007-02-27 22:33:52


Hi,

i have a boost::variant holding some C++ types which have to be inserted
into the database :

boost::variant<int, std::string, double > dbColumnValueVar;

before i insert the value_type into the database
I need to call a processing function which is overloaded for every datatype
used in the variant
ie. each of these functions are defined

process ( int );
process ( std::string );
process ( double);
template <class T> process(T);
.....

what i do not understand is how do i use apply_visitor or some other tactic
to automatically dispatch the call to the right process function
as in :

boost::variant<int, std::string, double > dbColumnVar;
dbColumnVar = "hello world";
process ( dbColumnVar ); // should call process std::string ....but is
always calling the generic template version ??
dbColumnVar = 1.3434;
process ( dbColumnVar ); //again calls generic template not specialization

cout << dbColumnVar
 is somehow able to get the correct overloaded << operator for the hidden
datatype
irrespective of datatype ??

Any help will be appreciated

Thanks
Digz



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