Boost logo

Boost :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-28 14:44:26


AMDG

Mathias Gaunard wrote:
> typedef mpl::map<
> mpl::pair<
> mpl::string<'D', 'e', 'r', 'i', 'v', 'e', 'd', '1'>,
> Derived1
> >,
> mpl::pair<
> mpl::string<'D', 'e', 'r', 'i', 'v', 'e', 'd', '2'>,
> Derived2
> >,
> mpl::pair<
> mpl::string<'D', 'e', 'r', 'i', 'v', 'e', 'd', '3'>
> Derived3
> >
> > derived_types;
>

I think that you should associate the name with the types
and then specify a list of types.

template<>
struct name_of<Derived1> : mpl::string<'D', 'e', 'r', 'i', 'v', 'e',
'd', '1'> {};

//...

typedef mpl::vector<Derived1, Derived2, Derived3, ..., DerivedN>
derived_types;

Hmmm... This seems rather reminiscent of Typeof registration.

> Is there some interest in such a tool?
>

Any chance that this could be generalized a bit to dispatching on
a type_info object, so it can be used with any, too e.g.?

struct Visitor {
    boost::any& any_;
    template<typename T>
    void operator()(wrap<T>) {
        T& t = boost::any_cast<T&>(any_);
    }
};

In Christ,
Steven Watanabe


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