Boost logo

Boost :

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


--- "E. Gladyshev" <egladysh_at_[hidden]> wrote:
[...]
> 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& );
> };

After thinking about it, I doubt that the compiler
will able to resolve the above overloads for
binary visitors.

For example,

visitor v;
int x;
boost::empty y;
v( x, y ); //error: unresolved overloads

If this is true, then overloads is not a solution.
I do use binary overloads in my code.

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