Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] Introspection of fused objects?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-02-25 21:26:10


AMDG

Rutger ter Borg wrote:
> Suppose I have a function object created on the basis of a sequence of fused
> function objects, where I would like to do shuffle the call order on the
> basis of some criterion.
>
> template< typename SeqOfFused >
> struct merge_fused {
>
> merge_fused( SeqOfFused f ): m_functions( f ) {}
>
> typedef void result_type;
>
> template< int N, typename Seq >
> void operator()( Seq& seq ) {
>
> // normal dispatch call would be fusion::at_c<N>(m_functions)( seq );
>
> if ( some case ) {
> store seq for later use
> } else {
> call appropriate fused object with parts of stored stuff
> }
> }
>
> SeqofFused m_functions;
>
> // some state / memory specific to this group of fused objects
> some_state m_state;
> };
>
> I'm doing a static cast to a superclass to get rid of the int N template
> parameter, to make the merge_fused look exactly like a fused function
> object. This works fine.
>

What are you casting to a superclass?

> Storing stuff is what my question is about: is there any way to know the
> type of Seq from its Fused counterpart? Looking at the code, the answer is
> no, but perhaps there exists introspection code in fusion which I am unaware
> of?
>

What is the "Fused Counterpart" of Seq.

> One solution would be to simply use static casting based on Seq in
> operator(), but then my question would be: is that safe?
>

Is Seq always that same type? It sounds dangerous, but I don't really
understand what you want to do.

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