[Boost-users] [fusion] "real" return types

2 views
Skip to first unread message

Stefan Strasser

unread,
Aug 19, 2009, 8:06:56 PM8/19/09
to boost...@lists.boost.org
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.

thank you

_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Steven Watanabe

unread,
Aug 19, 2009, 6:28:07 PM8/19/09
to boost...@lists.boost.org
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

Reply all
Reply to author
Forward
0 new messages