Dear Boost experts,

I'm trying to find a solution to the following problem.

I'm iterating over an MPL sequence and once I found the appropriate type in the sequence
I call a static function that returns a pointer to a newly created object that I need to return to the caller of the ModelDispatcher::parse member function with its exact type.
In other words I need to propagate the exact type of the object created somewhere in a recursive chain of function calls back to the original caller.
Unfortunately I can't figure out how to specify the return type of this recursive function.


Every type in the sequence has the following form:

struct sequence_item
{
    typedef the_real_type type ;
    static the_real_type *parse( const QDomElement & ) ;
} ;


The code for iterating over the sequence is the following:


template < typename It, typename End >
?? *dispatchM( const QDomElement &, mpl::true_ /* endofvec */ )
{
    return 0 ;
}


template < typename It, typename End >
?? *dispatchM( const QDomElement &element, mpl::false_ )
{
    typedef typename mpl::deref< It >::type MapEntry ;
    if ( element.tagName() == MapEntry::first::name() )
        {
            // return type is MapEntry::second::type
            return MapEntry::second::parse( element ) ;
        }
    else
        {
            typedef typename mpl::next< It >::type Next ;
            return dispatchM< Next, End >( element, typename boost::is_same< Next, End >::type() ) ;
        }
}


template < typename ModelMap >
struct ModelDispatcher
{
    static
    ?? *parse( const QDomElement &element )
    {
        mpl::false_ f ;
        return dispatchM< typename mpl::begin< ModelMap >::type, typename mpl::end< ModelMap >::type >( element, f ) ;
    }
} ;



Thanks a lot for your help.

Istvan