我需要将值映射到 std::string (使用以下映射和 BOOST_FUSION_ADAPT_STRUCT )
std::map< TYPEX, std::string> author2name;
struct Emp
{
std::string name;
TYPEX author;
};
使用以下代码,我想生成我的输出:
karma::rule< it, std::string()> quote = '"' >> karma::string >> '"';
karma::rule< it, Emp> emp = karma::delimit('\t')[ quite << quite[ author2name[ karma::_1] ]];
Emp x;
karma::generate( std::ostream_iterator<char>(std::cout), emp, x);
但它不编译。
有没有办法我可以写这样的标题:
karma::rule< it, std::vector<std::string>()> header = karma::delimit('\t')[ % quote];
karma::rule< it, Emp> emp = header >> karma::eol >> karma::delimit('\t')[ quite << quite[ author2name[ karma::_1] ]];
karma::generate( std::ostream_iterator<char>(std::cout), {"A", "B", "C"},emp, x);