|
Boost Users : |
Subject: Re: [Boost-users] [fusion] "real" return types
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-08-19 18:28:07
AMDG
Stefan Strasser wrote:
> I have a problem with boost.fusion I can't figure out from the documentation.
>
> consider the following example:
>
> template<class Vector>
> ? function(Vector vec){
> return fusion::push_back(vec,123);
> }
>
> what is the return type ?
> the return type is supposed to be a random access sequence, so
> result_of::push_back<Vector,int>::type is not an option, because push_back
> only returns a forward sequence.
> so I have to construct a new vector from the view that push_back returns.
> if Vector was vector<char,short> I need to find the type
> vector<char,short,int>, preferrably without an own MPL algorithm since this
> is only a simple test case, the real return type is much more complex and
> based on more than one transformation function.
>
you'll need something like this:
typename fusion::result_of::as_vector<
typename fusion::result_of::push_back<Vector, int>::type
>::type
In Christ,
Steven Watanabe
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