#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;
}