I'm not understanding something about the interaction of map with
the algorithms. I've got a map whose value_type is another map.
I'd like to iterate through the map entries and add all the "sub-map"
entries to the "primary" map. I wrote a little testcase, attached
below. When I compile it with g++ 3.3.3, I get this:
boost-1_32/boost/mpl/pair.hpp: In instantiation of
`boost::mpl::second':
fold2.cc:23: instantiated from
`boost::mpl::value_type_implboost::mpl::aux::map_tag::apply'
fold2.cc:23: instantiated from `boost::mpl::value_type'
fold2.cc:23: instantiated from here
boost-1_32/boost/mpl/pair.hpp:56: error: no
type named `second' in `struct mpl_::_2'
fold2.cc:23: error: `types' is not a member of type `
boost::mpl::value_type'
fold2.cc:24: error: template argument 1 is invalid
fold2.cc:24: error: ISO C++ forbids declaration of `type name' with no type
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp: In
instantiation of `boost::mpl::apply_wrap2 >':
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp:49:
instantiated from `boost::mpl::apply2 >'
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp:49:
instantiated from `boost::mpl::aux::fold_impl<1,
boost::mpl::m_iter, boost::mpl::m_iter, map_types, int>'
boost-1_32/boost/mpl/fold.hpp:39: instantiated from
`boost::mpl::fold'
fold2.cc:24: instantiated from here
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp:49: error: `
int' is not a class, struct, or union type
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp: In
instantiation of `boost::mpl::aux::fold_impl<1,
boost::mpl::m_iter, boost::mpl::m_iter, map_types, int>':
boost-1_32/boost/mpl/fold.hpp:39: instantiated from
`boost::mpl::fold'
fold2.cc:24: instantiated from here
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp:49: error: no
type named `type' in `struct boost::mpl::apply2 >'
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp: In
instantiation of `boost::mpl::aux::fold_impl<1,
boost::mpl::m_iter, boost::mpl::m_iter, map_types, int>':
boost-1_32/boost/mpl/fold.hpp:39: instantiated from
`boost::mpl::fold'
fold2.cc:24: instantiated from here
boost-1_32/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp:53: error: no
type named `type' in `struct boost::mpl::apply2 >'
boost-1_32/boost/mpl/fold.hpp: In instantiation of
`boost::mpl::fold':
fold2.cc:24: instantiated from here
boost-1_32/boost/mpl/fold.hpp:39: error: no
type named `state' in `struct boost::mpl::aux::fold_impl<1,
boost::mpl::m_iter, boost::mpl::m_iter,
map_types, int>'
fold2.cc:24: error: syntax error before `;' token
fold2.cc:26: error: syntax error before `::' token
An EDG-based compiler gives much the same error.
What am I doing wrong?
Much thanks for the help!
-Dave
#include
#include
#include
#include
#include
#include
#include
#include
using namespace boost;
using namespace boost::mpl;
struct key1 {};
struct key2 {};
struct entry {
typedef map > types;
};
typedef map > map_types;
typedef fold::types,
inserter<_1, insert<_1, _2> > > >::type result;
result::blah; // Get a printout