Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-28 14:21:13


--- Fernando Cacciola <fernando_cacciola_at_[hidden]> wrote:
[...]
> > template< typename T >
> > template()( T& x )
> > {
> > x.f(); //** Here is the catch! We require that all variant types have f()
> > }
> > };

> How about not requiring a visitor overload for boost::empty?

Oh, I think I know what you mean.

struct visitor
{
  template< typename T >
  operator()( T& x )
  {
    x.f();
  };
  operator()( boost::empty& ) {}
};

It becames even more interesting for binary visitors.
All your visitors will need boost::empty overloads
and you would have to make sure that you are not
using types any other non-throw types to do
the optimization trick.

struct visitor
{
  template< typename T, typename U >
  operator()( T& x, U& u )
  {
    x.f( u ); //general function
  };
  //optimization stuff
  template<typename U> operator()( boost::empty&, U& );
  template<typename T> operator()( T&, boost::empty& );
  void operator()( boost::empty&, boost::empty& );
};

I guess I can live with it for now.

Eugene

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/


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