
Hi, I'm trying to use the runtime mpl::for_each algorithm on an mpl::map that I have which associates enumerated values to various types. I want to be able to call a functor for each of the enumerated key values in the mpl::map but can't get the syntax right, I get the following compiler error with MSVC 9.0 c:\source\vendor\boost\1_38_0\boost\mpl\pair.hpp(43) : error C2039: 'first' : is not a member of 'boost::mpl::arg<1>' Any help appreciated. Mark. #include <iostream> #include <string> #include <boost/mpl/map.hpp> #include <boost/mpl/at.hpp> #include <boost/mpl/for_each.hpp> #include <boost/mpl/key_type.hpp> namespace mpl = boost::mpl; enum FieldId { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, _DaysInWeek }; // Map of enumerated types typedef mpl::map < mpl::pair< mpl::int_< Monday >, mpl::identity< int > >, mpl::pair< mpl::int_< Tuesday >, mpl::identity< std::string >
, mpl::pair< mpl::int_< Wednesday >, mpl::identity< int > >, mpl::pair< mpl::int_< Thursday >, mpl::identity< __int64 > >, mpl::pair< mpl::int_< Friday >, mpl::identity< char > >, mpl::pair< mpl::int_< Saturday >, mpl::identity< bool > >, mpl::pair< mpl::int_< Sunday >, mpl::identity< int > > _day_field_types;
// Returns the type for the associated enumeration template< int FIELD_ID > struct FieldTypeT : mpl::at< _day_field_types, mpl::int_< FIELD_ID >
::type {};
// Prints value struct printer { template< typename T > void operator()( const T& x ) { std::cout << x << std::endl; } }; int main() { // Print the associated type for the 'Tuesday' enumeration std::cout << typeid( FieldTypeT< Tuesday >::type ).name() << std::endl;; // Print the list of enumerations mpl::for_each< _day_field_types, mpl::key_type< mpl::map<>, mpl::_1 > >( printer() ); // Compiler error! }