[boost] [fusion] fusion::map doesn't define 'category'

I am attempting to create a fusion map which looks like: map< pair<field1, int>, pair<field2, int> > I am then attempting to find out if *field1 *exists in the map using *has_key, *but am getting a compile error: error: no type named ‘category’ in ‘struct boost::fusion::result_of::as_map<boost::fusion::vector2<boost::fusion::pair<field1, int>, boost::fusion::pair<field2, int> > > Can anyone offer insight on what I'm doing wrong? I have a simple example below: #include <iostream> #include <boost/fusion/container.hpp> #include <boost/fusion/sequence.hpp> #include <boost/fusion/mpl.hpp> #include <boost/fusion/include/has_key.hpp> #include <boost/mpl/transform.hpp> namespace fusion = boost::fusion; namespace mpl = boost::mpl; *// given a field, returns a fusion pair of <field, field::type>* template<class field> struct make_pair { typedef typename fusion::result_of::make_pair<field, typename field::type>::type type; }; *// given a sequence of fields, returns a fusion map which maps field -> field::type* template<class fields> struct make_map { typedef typename mpl::transform<fields, make_pair<mpl::_1>>::type pair_sequence; typedef typename fusion::result_of::as_map<pair_sequence> type; }; *// sets boolean value to true if field is in fields* template <class field, class... fields> struct contains_key { typedef typename boost::fusion::vector<fields...> vector; typedef typename make_map<vector>::type map; typedef typename fusion::result_of::has_key<map, field>::type result; static const bool value = result(); }; struct field1 { typedef int type; }; struct field2 { typedef int type; }; int main() { std::cout << contains_key<field1, field1, field2>::value << std::endl; return 0; }

D'oh - I found the error: typedef typename fusion::result_of::as_map<pair_sequence> type; should be typedef typename fusion::result_of::as_map<pair_sequence>::type type; On 27 July 2012 13:48, Steve Lorimer <steve.lorimer@gmail.com> wrote:
I am attempting to create a fusion map which looks like:
map< pair<field1, int>, pair<field2, int> >
I am then attempting to find out if *field1 *exists in the map using *has_key, *but am getting a compile error:
error: no type named ‘category’ in ‘struct boost::fusion::result_of::as_map<boost::fusion::vector2<boost::fusion::pair<field1, int>, boost::fusion::pair<field2, int> > >
Can anyone offer insight on what I'm doing wrong?
I have a simple example below:
#include <iostream> #include <boost/fusion/container.hpp> #include <boost/fusion/sequence.hpp> #include <boost/fusion/mpl.hpp> #include <boost/fusion/include/has_key.hpp> #include <boost/mpl/transform.hpp>
namespace fusion = boost::fusion; namespace mpl = boost::mpl;
*// given a field, returns a fusion pair of <field, field::type>* template<class field> struct make_pair { typedef typename fusion::result_of::make_pair<field, typename field::type>::type type; };
*// given a sequence of fields, returns a fusion map which maps field -> field::type* template<class fields> struct make_map { typedef typename mpl::transform<fields, make_pair<mpl::_1>>::type pair_sequence; typedef typename fusion::result_of::as_map<pair_sequence> type; };
*// sets boolean value to true if field is in fields* template <class field, class... fields> struct contains_key { typedef typename boost::fusion::vector<fields...> vector; typedef typename make_map<vector>::type map; typedef typename fusion::result_of::has_key<map, field>::type result;
static const bool value = result(); };
struct field1 { typedef int type; }; struct field2 { typedef int type; };
int main() { std::cout << contains_key<field1, field1, field2>::value << std::endl; return 0; }

2012/7/27 Steve Lorimer:
I am attempting to create a fusion map which looks like:
map< pair<field1, int>, pair<field2, int> >
I am then attempting to find out if field1 exists in the map using has_key, but am getting a compile error:
error: no type named ‘category’ in ‘struct boost::fusion::result_of::as_map<boost::fusion::vector2<boost::fusion::pair<field1, int>, boost::fusion::pair<field2, int> > >
http://liveworkspace.org/code/939832539ec300274d05282ec870e954 -- Regards, niXman ___________________________________________________ Dual-target(32 & 64 bit) MinGW compilers for 32 and 64 bit Windows: http://sourceforge.net/projects/mingwbuilds/
participants (2)
-
niXman
-
Steve Lorimer