Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2003-04-02 02:08:35


> > Also I think we need free function form of value
> > extraction. In other case it would be difficult to place extract
> > in context where template parameter is deduced. And check function
> > is not that important in most cases.
>
> While I am again considering a free function, I'm not sure what
> difference it makes. Please elaborate.

template<typename T>
void foo( T const& )
{
 ....
}

int main()
{
    boost::variant<int,.....> v = 5;

   // Here I want to pass const reference to integer value of variant to
function foo
  // foo( get<int>( v ) ); - type T is incorrect
   foo( ??? );
}

> Also, I think the functionality offered in extract::check is quite
> important. Unlike visitation, extract (or get, or whatever) handles
> only one of several possible states of the given variant object.

But you are calling check inside access method and throw an exception in
case of error. It should be enough in most cases IMO. Did I get you wrong.

Gennadiy.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk