Boost Spirit X3 和 std::unordered_map

Boost Spirit X3 and std::unordered_map

我想解析成 std::unordered_map

示例代码:

struct Base
{
  int item1;
  int item2;
};

BOOST_FUSION_ADAPT_STRUCT(Base, item1, item2)

namespace grammar
{
  using namespace boost::spirit::x3;

  auto base_ = rule<struct base_, Base>{"base"}
             = repeat(2)[ int_ ];

  auto start = rule<struct start, std::unordered_map<std::int32_t, Base>>{"start"}
             = (id_ >> base_) % eol;
}

主要有以下内容:

namespace ios = boost::iostreams;
namespace fs  = boost::filesystem;
namespace x3  = boost::spirit::x3;

int main()
{
   std::unordered_map<std::int32_t, Base> bases;

   ios::mapped_file mmf("example.dat");

   auto beg = std::begin(mmf);
   auto end = std::end(mmf);

   auto ret = x3::phrase_parse(beg, end, grammar::start, x3::char_(','), bases);

   if (ret && beg == end)
   {
      std::cout << "Parse ok\n";
   }

   mmf.close();

   return 0;
}

和一个示例文件:

1,2,3
2,3,4
3,4,5

编译器错误信息为:

.... ‘class std::unordered_map<int, Base>’ has no member named ‘push_back’

接下来怎么办,有没有办法适应std::unordered_map

Likee jv_ 假设,更新我的 boost 版本解决了这个问题。