Boost logo

Boost Users :

From: Joel de Guzman (joel_at_[hidden])
Date: 2006-08-22 21:28:17


Christian Henning wrote:
> Thanks, that worked now. I like the fusion::for_each loop, it's very handy!
>
> Anyway, when I started this thread I actually had something else in my
> mind. As you can see the doSomething() is templated. I would like to
> create a type vector depending on the template parameter, here S. Is
> that possible?
>
> I could image to have something like this ( beware bad pseudo code ):
>
> template <class S> void doSomething( S& s )
> {
> //create vector depending on S's length
> typedef fusion::vector<S::num_values> vec; // vector length
>
> // add the members type to vec
> fusion::for_each_member( s, vec.add() );
>
> // create boost tuple type out of vec
> fusion::make_tuple( vec );
> }
>
> Am I totally fantasying here? I think all the infomation are available
> at compile time.

Creating a type vector depending on the template parameter, S, is
certainly OK. I'll have to ignore the "bad pseudo code" though ;)
You have to do it another way. Tell me precisely what you wish
to do and I may be able to provide an example. Actually, I am
compiling a small set of simple use-case examples. You wouldn't
mind if I use our first example, would you?

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net