I want to express a "type-mapping" scheme. My implementation idea is
Brian Simpson wrote: this:
have the user define an MPL sequence comprised exclusively of std::pair derivations. He can then instantiate my template class with his sequence as the argument. My template then derives two MPL sequences, one containing the "first" types, the other containing the "second" types. Here is the attempt: <code> namespace ls { using namespace boost::mpl; using namespace placeholders;
template <class TypePairSequence> struct list_splitter { template <class STDPAIR> struct first_type { typedef typename STDPAIR::first_type type; }; template <class STDPAIR> struct second_type { typedef typename STDPAIR::second_type type; };
typedef typename transform < TypePairSequence , first_type<_1> > ::type first_types;
typedef typename transform < TypePairSequence , second_type<_1> >::type second_types; };
}//end namespace ls </code>
Here is an attempt to instantiate: 1> typedef boost::mpl::list< std::pair
, std::pair associated_types; 2> typedef ls::list_splitter
split_associated_types; 3> typedef split_associated_types::first_types first_types; 4> typedef split_associated_types::second_types second_types; 5> typedef boost::mpl::at_c ::type first_first_t; Code lines 1-2 compile fine. When I add line 3, I get the following error: "no type named `first_type' in `struct boost::mpl::arg<1>'".
[...]
I'm sure I'm overlooking something simple. Could someone point me in the right direction? I'm using gcc3.2.2 on Solaris 9.
Brian, I don't have access to gcc 3.2.2 at the moment, but it looks like
they are still not able to handle the class template arity issues
correctly (your example also fails with an internal compiler error on 3.2).
The essence of the issue is that gcc adopts a non-standard extension
under which two class template specializations like these
template< typename T > struct lambda { typedef T type; };
template<
template< typename > class F
, typename T1
>
struct lambda< F<T1> >
{
};
template<
template< typename, typename > class F
, typename T1, typename T2
>
struct lambda< F