Boost logo

Boost :

From: Peng Yu (pengyu.ut_at_[hidden])
Date: 2007-07-17 09:27:37


On 7/17/07, Peng Yu <pengyu.ut_at_[hidden]> wrote:
> On 7/16/07, Mathias Gaunard <mathias.gaunard_at_[hidden]> wrote:
> > Peng Yu wrote:
> >
> > > I've seen typelist somewhere. I'm wondering if it is defined in boost?
> >
> > Boost has better than that, it has the Boost Meta-Programming Library
> > (MPL) that contains various data structures and algorithms around types.
>
> Hi,
>
> I saw list in mpl. But I'm not familiar with it yet. Would you please
> show me how to do the same thing in mpl as that in my original email?

Hi,

I forgot mention that I use type_list in the following code. I'm
wondering how to replace type_list with mpl::list.

Thanks,
Peng

class A;
class B;

typedef type_list<A, type_list<B> > AB;

class base {
  public :
    virtual ~base() {}
    virtual void accept(base& b) = 0 ;
};

template <typename TL, typename Base>
class visitor : public visitor<typename TL::tail, Base> {
  public :
    virtual ~visitor() { }
    virtual void visit(typename TL::head &) {
       std::cout << __PRETTY_FUNCTION__ << std::endl;
    }
    using visitor<typename TL::tail, Base>::visit;
// no visit() function defined for visitor<list_end, Base>
// is there any way to make the above using statement conditional?
// (if the base class is visitor<list_end, Base>, not to use this statement.)
};

template <typename Base>
class visitor<list_end, Base> : public Base {
  public :
    virtual ~visitor() { }

};


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