|
Boost : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2003-10-23 04:54:24
David B. Held <dheld_at_[hidden]> wrote:
> Ok, now I want to create an mpl::vector of std::vectors,
> instantiated over the types in my sequence. I think this
> is what I want, but I want to make sure it's the best way:
>
> template <typename T>
> struct make_vector
> {
> typedef std::vector<T> type;
> };
>
> template <typename T>
> struct foo
> {
> typedef typename as_sequence<T>::type seq;
> typedef typename transform<seq, make_vector<_1> >::type my_vec;
>
> tuple<elements_of_my_vec> v;
> };
>
> foo f;
>
> get<3>(f.v);
>
> Obviously, my problem is making a tuple from an mpl::vector.
> I sure hope this is possible and easy, because it would totally
> rock if it is.
The Fusion lib (in the sandbox) hopefully to replace the old tuple lib
can do that easily (example):
typedef boost::mpl::list<int, double, X, int> mpl_list1;
type_sequence<mpl_list1> view;
std::cout << generate(view) << std::endl;
generate(view) creates a tuple from the view.
Cheers,
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk