$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] [fusion] Introspection of fused objects?
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2010-02-17 08:44:49
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. 
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?
One solution would be to simply use static casting based on Seq in 
operator(), but then my question would be: is that safe?
Thanks,
Rutger